I have only started with Django recently, and assume there must be a good solution for this issue!
After installing django-allauth through pip, it tried to extend base.html
from my project/templates
folder rather than from its own subdirectory. This user had the same issue and was told to rename one of the base.html
files and then update all references to it in the related app templates. For a complex app (already bad), this is error-prone; it's even worse if multiple third party apps are each defining their own base.html
and referring to it simply as {% extends 'base.html' %}
. Also, I think this only applies to third party apps, since I can easily name base.html something different for each of my own apps, but I don't want to mess around with 3rd party apps that work.
My question is: is there a safe/easy way to allow multiple third-party apps to use {% extends 'base.html' %}
without clashing?
I have read the docs on template inheritance in Django and understand that:
- By default, templates are loaded from the filesystem first, and then from app subdirectories. Therefore my
projects/templates
directory, which is defined in myTEMPLATE_DIRS
setting, will be called first; hence the django-allauth problem. - I can reverse this order for the app subdirectory to be called first, by changing the order of
TEMPLATE_LOADERS
. However, this just means that my website will now extend the wrongbase.html
.
Although I can fix the current clash by renaming allauth's base.html
as allauthbase.html
and changing child template references to it as {% extends 'allauthbase.html' %}
, this seems bulky.
Most wierdly, this person is complaining that each app extends its own base.html by default, but that seems impossible...