On Thu, Mar 11, 2010 at 4:54 PM, russianbandit <russianban...@gmail.com> wrote: > I'm using UserProfile to add one field to my users. However, I know > that I must explicitly create UserProfile for each new user that > registers. So, I make a UserProfile upon registration. Is UserProfile > still the best way to extend the user model? > What about the admin user, or users that the admin creates? Since they > don't go through the registration process, how do I ensure that their > UserProfile gets created? >
Add this to your models.py from django.db.models.signals import post_save from django.contrib.auth.models import User def _hook_save_user(instance, sender, **kwargs): try: instance.get_profile() except UserProfile.DoesNotExist: UserProfile.objects.get_or_create(user=instance) post_save.connect(_hook_save_user, sender=User) Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.