Alexis
Alexis

Reputation: 25193

How to get user permissions of user currently in Django admin site

I have certain fields that I would only like displayed to certain admins when they are in the admin site. I am looking into using list_display to do this but first need to figure out a way of determining which user is currently viewing the admin site.

Upvotes: 0

Views: 142

Answers (1)

Michael Mior
Michael Mior

Reputation: 28752

Unless you pass the request object everywhere, the solution is generally to use thread local storage and some middleware that updates the value on each request.

http://djangosnippets.org/snippets/2179/

Upvotes: 1

Related Questions