4👍
✅
You already have the UserProfile instance when you done request.user.userprofile
,
at this point, you have a Instance of UserProfile. you can’t use the object manager (.objects
) from that.
you only need
changepass = request.user.userprofile
Another way to get the userprofile object, is doing
UserProfile.objects.get(user=request.user)
3👍
You can’t access a Manager through a Model instance. In your case, request.user
is an instance of the User
class.
To access the manager, you need to use the UserProfile
class directly.
Although, for what you’re trying to accomplish, it’s much easier to transverse the database through the request’s user object:
changepass = request.user.userprofile
- [Django]-Django send_mail get result
- [Django]-Translate xml string to Python list
- [Django]-ModelForm and error_css_class
- [Django]-Which is the best python framework for developing Facebook application as on now
- [Django]-Postgres to Ubuntu Docker container linking not working
- [Django]-Displaying pyqtgraph and pyqt widgets on web
- [Django]-Django: Timezone stored in MySQL DB is not correct
- [Django]-Django: Moving from XAMPP to Django questions
Source:stackexchange.com