Django admin base.html template

110 views
Skip to first unread message

Mike Dewhirst

unread,
Apr 28, 2017, 1:39:07 AM4/28/17
to Django users
I would like to suggest a small change to
contrib/admin/templates/admin/base.html ...

33 {% block userlinks %}
34 {% if site_url %}
35 <a href="{{ site_url }}">{% trans 'View site' %}</a> /
36 {% endif %}
37 {% if user.is_active and user.is_staff %}
38 {% url 'django-admindocs-docroot' as docsroot %}
39 {% if docsroot %}
40 <a href="{{ docsroot }}">{% trans
'Documentation' %}</a> /
41 {% endif %}
42 {% endif %}
43 {% if user.has_usable_password %}
44 <a href="{% url 'admin:password_change' %}">{% trans
'Change password' %}</a> /
45 {% endif %}
46 <a href="{% url 'admin:logout' %}">{% trans 'Log out'
%}</a>
47 {% endblock %}

... to include a new block around the docsrootfrom line 37 (above) to 42
inclusive. The business case (for me) is that ordinary user.is_staff
users have no interest in the innards of the design, models, tags etc.
Superusers are interested but not the others.

Hence, if that bit of the template were surrounded by a new block - say
{% docs %} - then I could over-ride just that bit and send ordinary
users to the user-documentation instead.

Thoughts?

Mike

Mike Dewhirst

unread,
Apr 28, 2017, 1:56:42 AM4/28/17
to Django users
For example - see below


On 28/04/2017 3:38 PM, Mike Dewhirst wrote:
> I would like to suggest a small change to
> contrib/admin/templates/admin/base.html ...
>
> 33 {% block userlinks %}
> 34 {% if site_url %}
> 35 <a href="{{ site_url }}">{% trans 'View site'
> %}</a> /
> 36 {% endif %}
{% block docs %}

> 37 {% if user.is_active and user.is_staff %}
> 38 {% url 'django-admindocs-docroot' as docsroot %}
> 39 {% if docsroot %}
> 40 <a href="{{ docsroot }}">{% trans
> 'Documentation' %}</a> /
> 41 {% endif %}
> 42 {% endif %}
{% endblock %}
> 43 {% if user.has_usable_password %}
> 44 <a href="{% url 'admin:password_change' %}">{% trans
> 'Change password' %}</a> /
> 45 {% endif %}
> 46 <a href="{% url 'admin:logout' %}">{% trans 'Log
> out' %}</a>
> 47 {% endblock %}

Or in full from line 33 in contrib/admin/templates/admin/base.html

{% block userlinks %}
{% if site_url %}
<a href="{{ site_url }}">{% trans 'View site' %}</a> /
{% endif %}
{% block docs %}
{% if user.is_active and user.is_staff %}
{% url 'django-admindocs-docroot' as docsroot %}
{% if docsroot %}
<a href="{{ docsroot }}">{% trans
'Documentation' %}</a> /
{% endif %}
{% endif %}
{% endblock %}
{% if user.has_usable_password %}
<a href="{% url 'admin:password_change' %}">{% trans
'Change password' %}</a> /
{% endif %}
<a href="{% url 'admin:logout' %}">{% trans 'Log out'
%}</a>
{% endblock %}

Cheers

Mike
Reply all
Reply to author
Forward
0 new messages