[Answered ]-Extending the User model with custom fields in Django

2👍

First of all: are you absolutely sure that you put the correct value for AUTH_PROFILE_MODULE in your settings.py file? Because the exception should look different if there was no UserProfile for this user. (DoesNotExist)

Anyway: there is no UserProfile object at that time, because it is not generated automatically. So get_profile() raises an exception in your case.

Either do this:

if not UserProfile.objects.filter(user=user):
    p = UserProfile(user=user)
    p.save()
uinfo = user.get_profile()
...

or create a signal as (loosely) described at http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Leave a comment