Dynamic User Menu in Django -


Is there a user menu that has changed the user group according to the specified permission, which is a user? I'm thinking something which checks these permissions at the scene level, and also removes menu options, which the user is not allowed to.

Yes, it is possible to use the user object in the template and check whether the user is such an employee :

  {% user.is_staff%} & lt; Li & gt; ; & Lt; A href = "/ admin /" & gt; Admin & lt; / A & gt; & Lt; / Li & gt; {% Endif%}  

This would be an example where there are links to the items in your menu. Admin link will be provided only for users with is_staff status It can also be done with is_authenticated.

Django is designed to separate logic and presentation, so if you want to have some of the better granular control of the menu, then I am logic inside the idea, and then set a variable that Which menu to show to determine what you can check in the template.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -