question about userprofile

20 views
Skip to first unread message

Lorenzo Bernardi

unread,
Oct 7, 2014, 7:14:10 PM10/7/14
to django...@googlegroups.com
Hello,

I'd like to emphasize that it is probably a newbie question but I
don't know what are the keyword I should use for googling. So any
information would be helpful.

I'm trying to add a userprofile to my django app. The idea is to use
a sign-in system so that the user depending on who is can have access to
certain pages.

I think I understand the login part that is I define a user for my app
and make onetoone correspondance with the user table of django. I didn't
implement that yet but I think it should be easy and well documented.
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.

As I said any help is welcome.

sincerely


L.

Collin Anderson

unread,
Oct 7, 2014, 7:59:56 PM10/7/14
to django...@googlegroups.com, lorenzo....@lpn.cnrs.fr
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:
There's @permission_required decorator that you can wrap around your views.
In the templates, the users's permissions are available in {{ perms }}


Reply all
Reply to author
Forward
0 new messages