- 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.
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>
* owner: nobody => Daniel
* status: new => assigned
* stage: Unreviewed => Accepted
Comment:
Sounds reasonable.
--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:2>
--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:3>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:4>
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>
* 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>
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>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:8>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:9>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32987#comment:10>
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>
* 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>
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>
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>
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>
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>