Opened 3 years ago

Last modified 2 years ago

#32987 closed New feature

Warn user if they attempt to have mulitple templatetag libraries with the same name — at Version 1

Reported by: Daniel Owned by: nobody
Component: Template system Version: 3.2
Severity: Normal Keywords: template, check
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Daniel)

If a project has mulitple apps with templatetags with the same module name, django will load each of them, but drop all but the last one, and not inform the user at all, making it quite hard to diagnose.

For example, if you have:

  • blog/templatetags/navigation_tags.py
  • news/templatetags/navigation_tags.py
  • pages/templatetags/navigation_tags.py

then try to use them in a template:

{% load navigation_tags %}

then only one of these will be loaded - and there's no report that there is a problem - but if you attempt to use one of the filters / tags from one of the libraries that's not the loaded one, it throws a generic template syntax error saying it's an invalid tag / filter.

Proposed solution:

Add a new 'check' to the django checks that warns the user if there are multiple templatetag libraries with the same name.

see PR:

https://github.com/django/django/pull/14735

Change History (1)

comment:1 by Daniel, 3 years ago

Description: modified (diff)
Summary: If multiple apps have templatetags modules with the same name, it silently drops all but one.Warn user if they attempt to have mulitple templatetag libraries with the same name
Note: See TracTickets for help on using tickets.
Back to Top