Issue #144 new

A way to reduce copy and paste in admin-tools templates

created an issue

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

This makes it more painful to support multiple Django versions and update to new Django versions.

It also increases the chance you'll have conflicts with other apps that also need to modify base.html.

There is a simple project called django-apptemplates that provides a custom template loader:

At the cost of introducing another dependency - it would allow you to both extend and override a template at the same time and would therefore reduce base.html to just this:

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

I've done this on my own fork of django admin tools and it works well:

If you used django-apptemplates, you wouldn't even really need to override base.html yourself. The changes needed are simple enough that you could just document them and tell people to add 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 base.html to use - with your current approach it becomes tricky for me to use that alongside django-admin-tools.

Comments (0)

  1. Log in to comment