In my views.py file on my Django site, I have a class based view that needs to alter a variable based on the user's permissions.
So if a user has the pro_view permission, then it sees one thing. Otherwise if it has basic_view then it sees another.
How can I access this inside my get_context_data(self, **kwargs): function?
Use has_perm:
So, from inside your get_context_data you can do something like this:
if self.request.user.has_perm('applications.admin_access'):
# do this
else:
# do that
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With