Would this be a way to reduce copy/paste code in base.html?

45 views
Skip to first unread message

Andy Baker

unread,
Feb 1, 2014, 2:48:36 PM2/1/14
to django-ad...@googlegroups.com
Hi, I'm new to admin-tools and have only started to investigate it today. Therefore I might be missing part of the bigger picture so please correct me if I have.

It appears that the theming app replicates all the code from Django's base.html but only really needs one change - adding the {% render_theming_css %} tag.

Doesn't this make it harder to support across different Django versions? Also - it increases the chance you'll clash with other apps that also need to modify base.html.

This custom template loader: https://bitbucket.org/tzulberti/django-apptemplates/ allows you to both extend and override a template at the same time and would therefore reduce base.html to just something like this:

    {% extends "admin:admin/base.html" %}
    {% load theming_tags %}
    {% block extrahead %}
        {{ block.super }}
        {% render_theming_css %}
    {% endblock %}

In fact - you wouldn't need to override it in the core app. You could document the above and tell people to supply their own base.html. That way it would be much easier for people to maintain other customizations. For example - I need to add a couple of tags to use https://github.com/DjangoAdminHackers/django-admin-blocks - with your current approuch it becomes tricky for me to use that app as well as django-admin-tools. 

Andy Baker

unread,
Feb 2, 2014, 6:46:06 AM2/2/14
to django-ad...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages