hello i’m new in python and django
I need a view that get current user profile I know I shoud use get_profile from User but I don’t know how to use it . i read the django document and It didn’t help me.
this is what I found from doc:
from django.contrib.auth.models import User
profile=request.user.get_profile()
Django’s documentation says it all, specifically the part Storing additional information about users. First you need to define a model somewhere in your
models.pywith fields for the additional information of the user:models.py
Then, you need to indicate that this model (
UserProfile) is the user profile by settingAUTH_PROFILE_MODULEinside yoursettings.py:settings.py
You need to replace
accountswith the name of your app. Finally, you want to create a profile every time aUserinstance is created by registering apost_savehandler, this way every time you create a user Django will create his profile too:models.py
Accessing the Profile
To access the current user’s profile in your view, just use the
Userinstance provided by the request, and call get_profile on it: