1. David Jean Louis
  2. django-admin-tools
  3. Issues
Issue #144 new

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

Andy Baker
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: https://bitbucket.org/tzulberti/django-apptemplates/

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:

https://bitbucket.org/ixxy/django-admin-tools/commits/9222758ce5036a2165882b5b6738afbc53762df5 https://bitbucket.org/ixxy/django-admin-tools/commits/3ef5e08d1b56203bc89609af63c84e968d103c80

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 https://github.com/DjangoAdminHackers/django-admin-blocks - with your current approach it becomes tricky for me to use that alongside django-admin-tools.

Comments (0)

  1. Log in to comment