1đź‘Ť
Check this answer for discussion on user.is_authenticated
. You can also check within the view to see who the user is (see here) and modify the context being sent to the template accordingly. Another option would be to modify your view to simply show different types of users different templates.
Lots of ways to accomplish this, not sure if there’s a “correct” one.
Your comment made me realize that this is exactly what the Groups feature of the auth
package is for. You can assign users to groups, query whether they’re a member of the group, and then show content based on that. I apologize that I don’t have time to write out sample code, but there’s tons of stuff here on SO about it; hopefully that’s a good starting point for you.
1đź‘Ť
I don’t know if it is good style. But you could use
{% include user_type_sidemenu_template with arg1=... %}
in your template and provide different templates for the sidemenu for each user_type
. You can then set the template variable user_type_sidemenu_template
to the corresponding template name in your view.
- [Answered ]-Mix raw and ORM operations within the same Django transaction?
- [Answered ]-When should the hostname be in ALLOWED_HOSTS
- [Answered ]-Django: call standard command from a custom command
- [Answered ]-Searching by Username field in Django admin
- [Answered ]-400 Bad Request in Google Oauth2 for access token