views:

1290

answers:

2

Is there a way to have a user menu that'll change according to the permissions assigned to the user group a user belongs to? I'm thinking of something that checks for these permissions at the view level, and also removes menu options a user doesn't have permission to.

+2  A: 

For the most part, django's admin already doesnt give you links to things you can't do.

Django grappelli (a django admin skin) implements some sort of bookmarking, if that is what you mean http://code.google.com/p/django-grappelli/

phillc
+4  A: 

Yes it is possible to access the user object in the template and check if the user is staff like this:

{% if user.is_staff %}
    <li>
        <a href="/admin/">Admin</a>
    </li>
{% endif %}

This would be an example where your menu where li items of links. The admin link would only be rendered for users with is_staff status. The same could be done with is_authenticated.

Django is build to have logic and presentation separated, so if you want to do some more fine grained control of the menu, I would suggest doing the logic inside of the view, and then set a variable that you can check in the template to determine which menus to show.

googletorp
I was thinking along these lines...thanks for the quick help