Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should theming be overriding base.html the way it does? #21

Closed
andybak opened this issue Sep 2, 2015 · 3 comments
Closed

Should theming be overriding base.html the way it does? #21

andybak opened this issue Sep 2, 2015 · 3 comments

Comments

@andybak
Copy link
Contributor

andybak commented Sep 2, 2015

I spent an hour today working out why several Django 1.8 changes weren't showing up.

I'd used 'theming' to fix some CSS and it overrides base.html. So we need to update the included base.html to match the Django version

This means maintaining a different base.html for each Django version and figure out how to load the correct one for a given install.

Considering the only reasons for overriding it are to add a single tag loader and a tag that loads some CSS it strikes me that this is too high a price to pay.

There's also the problem that only one app can override base.html - if another app that tries the same technique then it's down to the ordering of INSTALLED_APPS

This can be partially solved with documentation - tell people what to put in their base.html if they need to - but it gets messy.

I wonder if this could be improved in Django core. I'm still mulling it over but I thought I'd start a conversation.

@andybak
Copy link
Contributor Author

andybak commented Sep 2, 2015

Within my own projects I've been using django-apptemplates: https://pypi.python.org/pypi/django-apptemplates/

This adds a template loader that namespaces 'extends' to a specific app. So I can do:

{% extends "admin:admin/base_site.html" %}

in my template and override only the blocks I need without getting a circular 'extends' loop.

This allows me to reduce the copy+paste from Django's base.html and means I'm much less likely to cause breakage when Django changes it's own html.

django-apptemplates is very small and simple so if another dependency is an issue we could include it in it's entirety.

@andybak
Copy link
Contributor Author

andybak commented Sep 2, 2015

Here's a similar alternative to apptemplate: https://github.com/stephenmcd/django-overextends

@izimobil
Copy link
Member

izimobil commented Sep 3, 2015

Yep, maintaining admin templates has always been a problem.
I'm usually against adding dependencies but in this case I'm +1 on using apptemplates (I prefer it to overextends btw). I did a quick test and it works great, I'll send a pull request, I have some time left today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants