Here is an example of determining whether a logged-in user has permissions for a model using Django's template language.
There is a default template variable called perms
, which can be used to make this determination.
{% if perms.myapp.view_mymodel %}
<li class="nav-item">
<a href="{% url 'admin:myapp_mymodel_changelist' %}" class="nav-link">Admin Page</a>
</li>
{% endif %}
Comments