django-userprofiles
django-userprofiles copied to clipboard
Django 1.5 AttributeError at /userprofiles/change/ 'NoneType' object has no attribute 'objects'
Does the contrib package still work with Django 1.5, I seem to be getting this error:
/home/chris/.virtualenvs/farm/local/lib/python2.7/site-packages/django/views/generic/edit.py in get_form
return form_class(**self.get_form_kwargs())
...
▼ Local vars
Variable Value
self
<userprofiles.contrib.profiles.views.ProfileChangeView object at 0x7fb1ac304350>
form_class
<class 'userprofiles.contrib.profiles.forms.ProfileForm'>
/home/chris/.virtualenvs/farm/local/lib/python2.7/site-packages/userprofiles/contrib/profiles/views.py in get_form_kwargs
kwargs['instance'] = get_profile_model().objects.get(
...
▼ Local vars
Variable Value
self
<userprofiles.contrib.profiles.views.ProfileChangeView object at 0x7fb1ac304350>
kwargs
{'initial': {}}
Are you using the the latest version of django-userprofiles? If yes, can you provide a code example which raises the error?
Hey,
Thanks for getting back to me, I am not at home right now but I will have a proper look at this towards the end of the week. Sorry it is not sooner.
All the best,
Chris
Did you have a chance to prepare a example to reproduce the error? As I can't find a way to get the error, I'll close the issue within the next days.
i am seeing same issue, using latest repository. the problem line is https://github.com/stephrdev/django-userprofiles/blob/master/userprofiles/contrib/profiles/views.py#L29 and get_profile_model() is returning null
all i've done is enable userprofiles.contrib.profiles in INSTALLED_APPS and browsed to /profile/change
the error exists because get_profile_model() returns None unless USE_PROFILE = True, which by default is False. i've fixed this by simply adding the following to my settings:
AUTH_PROFILE_MODULE = 'auth.User'
USERPROFILES_USE_PROFILE = True
this is followed by another error: Cannot resolve keyword 'user' into field. Choices are: date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, password, user_permissions, username. this comes from https://github.com/stephrdev/django-userprofiles/blob/master/userprofiles/contrib/profiles/views.py#L30.
i resolved this by changing user=self.request.user to id=self.request.user.id. admittedly i'm new to Python and Django so i'm not confident at all this is the proper fix.
Thanks. I'm going to write a patch for that.