question, if i want to attach the group name to user's session, so i can grab it in the template and use it to show or not show some content based on that, how do i accomplish that? today i can do it because i have local user in django db, but if i integrate with corporate AD, then i lose that flexibility. i wanna say, if you are part of this group you will not be able to see these content, or you will not be able to access these features, and so on.
Exclude the code based on conditionals with the django templating engine / Jinja2
Permit View:
Probably the cleanest way would be to create a decorator with functools.wraps.
In this decorator you'd get the group from the request and then permit or deny based on the group names.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
question, if i want to attach the group name to user's session, so i can grab it in the template and use it to show or not show some content based on that, how do i accomplish that? today i can do it because i have local user in django db, but if i integrate with corporate AD, then i lose that flexibility. i wanna say, if you are part of this group you will not be able to see these content, or you will not be able to access these features, and so on.
If I understand you correctly:
Hide Content:
Permit View:
Probably the cleanest way would be to create a decorator with
functools.wraps
.In this decorator you'd get the group from the request and then permit or deny based on the group names.