Thursday, April 27, 2017

Re: Django admin base.html template

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


>
> ... 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
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a8346b12-b484-2aa7-0090-224eb8c435ab%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment