1

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 my TEMPLATE_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 wrong base.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...

Community
  • 1
  • 1
gatlanticus
  • 1,158
  • 2
  • 14
  • 28

1 Answers1

0

It seems there is an open issue related to the problem: https://github.com/pennersr/django-allauth/issues/370

  • Thanks, I hadn't seen this. Still, I'd like to know if there's a solution, or if such apps are just considered to be poorly designed. – gatlanticus Feb 11 '15 at 23:41