profile = UserProfile.objects.get(....)
what i try to do - is to get profile for the currently logged in user. What should i put in the brackets?
profile = UserProfile.objects.get(....)
what i try to do - is to get profile for the currently logged in user. What should i put in the brackets?
Comon guys, no need to be so harsh... Some people actually don't know that the grey outline checkmark is what you're supposed to press.
UserProfile.objects.get(user=request.user)
But if it's a OneToOne
field, you should be able to do request.user.userprofile
http://docs.djangoproject.com/en/dev/topics/db/queries/#one-to-one-relationships
Assuming you are following the pattern described here:
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
You should be able to use the following: