Code

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#18617 closed Uncategorized (fixed)

Pointing out a template overriding pitfall

Reported by: EvilDMP Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I spent a lot of time trying to work out why my own base_site.html template wasn't overriding Django's.

Eventually I realised that it was because django.contrib.admin was listed in INSTALLED_APPLICATIONS before my own application, and so its base_site.html won the race to be chosen.

I'm a slow learner, so I went through the same thing all over again today, a year or more later...

To help people like me, I have added a comment in the settings.py of the project template, and a note in the docs, in a pull request at https://github.com/django/django/pull/185

Attachments (0)

Change History (4)

comment:1 Changed 2 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Yes, it's worth highlighting why the order of INSTALLED_APPS matters.

Other resolution mechanisms depend on the order of INSTALLED_APPS (static assets collection for example) and I don't feel like listing them in the default settings.py.

The pull request also contains a stray commit. I'll just take the patch to the template docs and commit it.

Last edited 2 years ago by aaugustin (previous) (diff)

comment:2 Changed 2 years ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from new to closed

In [8c670ee34714acffbc64e5cafd1e664fb8341a37]:

Fixed #18617 -- Highlighted that the app_directories template loader depends on the order of INSTALLED_APPS.

Thanks evildmp for the patch.

comment:3 Changed 2 years ago by EvilDMP

Thanks Aymeric - should I mark the pull request closed on GitHub, so it doesn't cause pollution?

comment:4 Changed 2 years ago by aaugustin

Yes, I've just closed it (I forgot when I committed the patch).

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.