Django's AUTH_PROFILE_MODULE ( User Profile ) misbehaving
-
07-03-2021 - |
Question
The Error -
"Caught FieldError while rendering: Cannot resolve keyword 'user' into field.
Choices
are: id, is_active_online, person"
The Model -
AUTH_PROFILE_MODULE = 'account.UserProfile'
class UserProfile(models.Model):
person = models.OneToOneField(User)
is_active_online = models.NullBooleanField(null = True, default = None)
The Origin of the error from a template -
{{ user_object.get_profile.is_active_online }}
What could be the issue?
Solution
https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
To make use of this feature, define a model with fields for the additional information you'd like to store, or additional methods you'd like to have available, and also add a OneToOneField named user from your model to the User model.
Your OneToOneField
needs to be named user
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow