1๐
โ
I guess that you have a model to handle user profile like this:
class UserProfile(models.Model):
"""Contains user profile fields not provided by User model"""
user = models.OneToOneField(User)
# Defined User profile fields like picture, phone, etc
So adding following line (maybe in your models.py after UserProfile
model):
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
Allows access to the profile of a user (i.e. in templates: {% user.profile.phone %}
) by creating it if not exists.
This is the way I solved in my site a problem like you describe.
Hope this helps
๐คjuliocesar
1๐
I am a bit confused. Are you trying to let users create account and sign in? Then use django-registration which is easy and works out of the box.
๐คuser2707389
Source:stackexchange.com