home / django_tickets / tickets

tickets: 16207

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
16207 2011-06-09 18:33:45 2011-06-25 12:39:57 2022-03-06 04:02:33.903554 Ready for checkin closed Documentation Bug Normal 1.3 fixed UserProfile documentation (not extensive enough) https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users# {{{The method get_profile() does not create the profile, if it does not exist. You need to register a handler for the signal django.db.models.signals.post_save on the User model, and, in the handler, if created=True, create the associated user profile.}}} However, it does not show how to do this. For new users, this will be quite off putting, especially as most people skim the documentation, and don't bother with the 'fat'. May I suggest the documentation is included to use the following snippet: http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django {{{ #in models.py from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): user = models.OneToOneField(User) #other fields here def __str__(self): return "%s's profile" % self.user def create_user_profile(sender, instance, created, **kwargs): if created: profile, created = UserProfile.objects.get_or_create(user=instance) post_save.connect(create_user_profile, sender=User) #in settings.py AUTH_PROFILE_MODULE = 'YOURAPP.UserProfile' }}} melinath foxwhisper userprofile 0 1 0 0 0 0
Powered by Datasette · Queries took 1.924ms