[Django]-Display link on template when user is a staff member in Django

9👍

Depending on your view it might be as simple as:

{% if request.user.is_staff %}
  <li><a href="{% url dashboard %}">{% trans 'Dashboard' %}</a></li>
{% endif %}
👤arie

7👍

It’s as simple as:

{# The following link should be displayed just to staff members #}
{% if request.user.is_staff %}
    <li><a href="{% url dashboard %}">{% trans 'Dashboard' %}</a></li>
{% endif %}

where user is the relevant user model, depending if you use Django’s vanilla User or you have overriding it.

👤nik_m

Leave a comment