I have a model in an app named user_profile
like so:
from django.db import models
from django.contrib.auth.models import User
class UserProfile
Er, you're trying to get the user profile of a UserProfile. I expect you mean to get a User, then call get_profile()
on that.
To anyone else that gets this error by following the old documentation, get_profile()
has been depreciated in django 1.7.
Instead you can just access the userprofile from the user as below..
u_p = user.userprofile
where userprofile
is the name of your UserProfile
class
You can also change to use the newer documentation by clicking on the desired version in the bottom right corner
I am using Django 1.8 and .userprofile
throws an error.
To get around this since I had profiles setup in Django 1.3, after upgrading to 1.8 I just changed .get_profile()
to profile
and it works.