1👍
✅
Another solution (involving not modifying the arguments to __init__()
, which may be troublesome) is to define which URLs need is_staff
in TOP_NAVIGATION_BAR
, like this:
TOP_NAVIGATION_BAR = [
{{'name': 'Secure', 'href': '/my_app/Secure', active: False, secure: True},
...
]
Now, you can carry out the check itself in the template (assuming your navigation menu appears in the template as the nav_menu
context variable):
{% for menu_item in top_menu %}
{% if not menu_item.secure or request.user.is_staff %}
<a href='{{ menu_item.href }}' ...
{% endif %}
{% endfor %}
0👍
You get request.user
as user
parameter in template (if you are using RequestContext
). This you can use to decide in your base/menu/header template to hide or show the tab.
- [Answer]-What kind of response should I return from a simple django AJAX view?
- [Answer]-Partial Load from Ember Model
Source:stackexchange.com