0

I would like to implement a function in Django admin, that if a person logged is superuser then the color in admin is different. How can I approach it?

I don't want 'normal' users to have access to admin, but I want to have 2 levels of access - superuser that can change everything (and add more personnel etc) and normal staff level, who can't add other employees and is limited in what he can do.

How can I approach the issue?

Can I simply add flag somewhere which states that if logged user is superuser then use different/additional css or something?

afdkj
  • 3
  • 3

1 Answers1

1

You can use the is_superuser check on the User object to determine if the user is a superuser or not a superuser.

Below is a sample code that you can use in your HTML

{% if request.user.is_superuser %}

<!---Add color code for admin--->

{% else %}

<!---Add color code for other users---->

{% endif %}
szm
  • 95
  • 8
  • 1
    Thank you very much! That is it. I created base_site.html which extends admin/base.html and gave css if user is superuser. Thank you! – afdkj Mar 27 '21 at 12:39