[Django] #32987: If multiple apps have templatetags modules with the same name, it silently drops all but one.

2 views
Skip to first unread message

Django

unread,
Aug 4, 2021, 4:47:56 AM8/4/21
to django-...@googlegroups.com
#32987: If multiple apps have templatetags modules with the same name, it silently
drops all but one.
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: nobody
Type: New | Status: new
feature |
Component: Template | Version: 3.2
system |
Severity: Normal | Keywords: template, check
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/32987>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 4, 2021, 4:49:40 AM8/4/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have mulitple templatetag libraries with the
same name
---------------------------------+--------------------------------------
Reporter: Daniel | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by Daniel:

Old description:

> 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

New description:

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

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:1>

Django

unread,
Aug 4, 2021, 6:44:16 AM8/4/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have mulitple templatetag libraries with the
same name
---------------------------------+------------------------------------
Reporter: Daniel | Owner: Daniel
Type: New feature | Status: assigned

Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Daniel
* status: new => assigned
* stage: Unreviewed => Accepted


Comment:

Sounds reasonable.

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:2>

Django

unread,
Aug 4, 2021, 1:24:42 PM8/4/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the

same name
---------------------------------+------------------------------------
Reporter: Daniel | Owner: Daniel
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:3>

Django

unread,
Aug 5, 2021, 4:51:09 AM8/5/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
---------------------------------+------------------------------------
Reporter: Daniel | Owner: Daniel
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:4>

Django

unread,
Oct 14, 2021, 3:07:39 PM10/14/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
---------------------------------+------------------------------------
Reporter: Daniel | Owner: Daniel
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Shreya Bamne):

The PR ([https://github.com/django/django/pull/14735]) mentioned in the
ticket was closed due to inactivity. I would like to continue working on
this. Would the correct next steps be to assign this ticket to myself,
open a new PR and link the old one there? I am new to the Django
community, any inputs are appreciated. Thank you.

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:5>

Django

unread,
Oct 14, 2021, 6:12:54 PM10/14/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
---------------------------------+----------------------------------------
Reporter: Daniel | Owner: Shreya Bamne

Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Shreya Bamne):

* owner: Daniel => Shreya Bamne


Comment:

I have started working on this ticket and assigning the ticket to me.

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:6>

Django

unread,
Oct 18, 2021, 3:44:56 PM10/18/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
---------------------------------+----------------------------------------
Reporter: Daniel | Owner: Shreya Bamne
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------

Comment (by Shreya Bamne):

Continuing on the previous work done on this ticket, here is the link to
the new PR: https://github.com/django/django/pull/15005

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:7>

Django

unread,
Oct 18, 2021, 11:57:16 PM10/18/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
---------------------------------+----------------------------------------
Reporter: Daniel | Owner: Shreya Bamne
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:8>

Django

unread,
Oct 19, 2021, 2:35:16 AM10/19/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
---------------------------------+----------------------------------------
Reporter: Daniel | Owner: Shreya Bamne
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:9>

Django

unread,
Oct 20, 2021, 5:08:00 AM10/20/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------

Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0


* needs_tests: 1 => 0

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:10>

Django

unread,
Oct 20, 2021, 7:27:42 AM10/20/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"b98394fa62753c867a287c2839696695557281a5" b98394f]:
{{{
#!CommitTicketReference repository=""
revision="b98394fa62753c867a287c2839696695557281a5"
Refs #32987 -- Refactored out get_template_tag_modules().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:11>

Django

unread,
Oct 20, 2021, 7:27:43 AM10/20/21
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: closed

Component: Template system | Version: 3.2
Severity: Normal | Resolution: fixed

Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"004b4620f6f4ad87261e149898940f2dcd5757ef" 004b4620]:
{{{
#!CommitTicketReference repository=""
revision="004b4620f6f4ad87261e149898940f2dcd5757ef"
Fixed #32987 -- Added system check for template tag modules with the same
name.

Co-authored-by: Daniel Fairhead <dan...@dev.ngo>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:12>

Django

unread,
Oct 2, 2022, 4:27:01 PM10/2/22
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: fixed
Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I wonder if we should reconsider the new behavior here. The problem is
that if in your project dependencies (which make sometimes a big list) you
have two tag libraries with the same name, the project won't be able to
migrate to Django 4.1. It's rather easily fixable when one of the libs is
in your project, but not when they both are from external deps. See
https://github.com/jazzband/sorl-thumbnail/issues/713

Could we at least make the check a warning, so it can be silenced?

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:13>

Django

unread,
Oct 2, 2022, 11:51:08 PM10/2/22
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: fixed
Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:13 Claude Paroz]:


> Could we at least make the check a warning, so it can be silenced?

Sounds reasonable, see [https://github.com/django/django/pull/16144 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:14>

Django

unread,
Oct 3, 2022, 4:52:50 AM10/3/22
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: fixed
Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"f71b0cf769d9ac582ee3d1a8c33d73dad3a770da" f71b0cf7]:
{{{
#!CommitTicketReference repository=""
revision="f71b0cf769d9ac582ee3d1a8c33d73dad3a770da"
Refs #32987 -- Relaxed system check for template tag modules with the same
name by turning into a warning.

Thanks Claude Paroz for the report.

Regression in 004b4620f6f4ad87261e149898940f2dcd5757ef.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:15>

Django

unread,
Oct 3, 2022, 4:53:33 AM10/3/22
to django-...@googlegroups.com
#32987: Warn user if they attempt to have multiple templatetag libraries with the
same name
-------------------------------------+-------------------------------------
Reporter: Daniel | Owner: Shreya
| Bamne
Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: fixed
Keywords: template, check | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"7843c43c49d3845a1cbebfaaf71f2f0c2a9d8fce" 7843c43c]:
{{{
#!CommitTicketReference repository=""
revision="7843c43c49d3845a1cbebfaaf71f2f0c2a9d8fce"
[4.1.x] Refs #32987 -- Relaxed system check for template tag modules with


the same name by turning into a warning.

Thanks Claude Paroz for the report.

Regression in 004b4620f6f4ad87261e149898940f2dcd5757ef.
Backport of f71b0cf769d9ac582ee3d1a8c33d73dad3a770da from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:16>

Reply all
Reply to author
Forward
0 new messages