Django Tutorial 9 - User Profile and @login_required decorator - Hacked Existence

preview_player
Показать описание
Django Tutorial 9 - User Profile and @login_required decorator

This tutorial covers the django get_profile() function which returns the profile for the authenticated user. It also covers the @login_required decorator which requires a user to be authenticated before they are able to see a specific view.
Рекомендации по теме
Комментарии
Автор

once you have the drinker instance from
drinker = request.user.get_profile()
you would follow the drinker objects foreign key to the user object and get the email field from the user object.

In the view this would be:
email = drinker.user.email

In a template this would be:
Email Addresss: {{ drinker.user.email }}

HackedExistence
Автор

If you are having problems with request.user.get_profile() to work, I would check the AUTH_PROFILE_MODULE in settings.py. It sounds like your profile modules are not installed properly. request.user gives you the User object attached to the request, request.user.get_profile() gives you the object defined in AUTH_PROFILE_MODULE in settings.py that is attached to the User object.

HackedExistence
Автор

agendaaaa - I've been meaning to switch to render and redirect, they were introduced in django 1.3, its more of a habit as I've been using django since 1.0. I will definitely try to make the transition moving forward, thanks for the tip.

HackedExistence
Автор

I'm getting this error !
NoReverseMatch at /resetpassword/
Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

swathirajanna
Автор

nice one - I just wonder - why don't u use render and redirect from django.shortcuts - make's life a little bit easier

agendaaaa
Автор

Thanks a million for great tutorial!
Unfortunately, in Django 1.7 there is no method "get_profile()" in User model. 

lifemixture
Автор

Great set of tutorials. Really helping me out. How would you go about making the profile editable? Is it possible to import the template like from the admin section that allows me to edit drinkers and display that to logged in users so they can edit their own profiles?

andrewwelch
Автор

Ah... Wrong Django...

 S. Grappelli

donjuandre