Tuesday, October 7, 2014

Re: question about userprofile

But after that I don't understand how I can use the information in the 
user table (like the pages that the user is allowed to enter) in django 
and how to set it somewhere. And also since I should change the menu to 
reflect that the user can go or not to one page how can I send this info 
to the template.
In a view, and in a template you should be able to use something like: request.user.userprofile
Basically it's request.user.<your model lower case>

As far as permissions go, there's really a lot of ways to do it, but I'll mention Django's permission system which might help you:
https://docs.djangoproject.com/en/1.7/topics/auth/default/#permissions-and-authorization
There's @permission_required decorator that you can wrap around your views.
https://docs.djangoproject.com/en/1.7/topics/auth/default/#the-permission-required-decorator
In the templates, the users's permissions are available in {{ perms }}
https://docs.djangoproject.com/en/1.7/topics/auth/default/#permissions


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3487a85b-f215-4b32-8125-6db42b8876a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment