Home > other >  Give permission if it is staff. django
Give permission if it is staff. django

Time:09-06

I have this code in django and I want the button to appear if the user is a super user or staff. I don't know how I should put it, I tried with is_superuser or is_staff but it didn't work.

{% if request.user == post.user %} <div > <a href="{% url 'delete' post.id %}"> <i style="color:#657786; font-size: 20px" aria-hidden="true"></i> </a> </div> {% endif %}

Code

CodePudding user response:

You could try with:

{% if request.user.is_superuser == True or request.user.is_staff == True %} <div > <a href="{% url 'delete' post.id %}"> <i  style="color:#657786; font-size: 20px" aria-hidden="true"></i> </a> </div> {% endif %}

CodePudding user response:

People already solved it, I just put an 'or user.is_superuser'

  • Related