Opened 6 years ago

Closed 6 years ago

#15680 closed (wontfix)

templatetags submodules no longer work

Reported by: EMiller Owned by: Julien Phalip
Component: Template system Version: 1.3
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

We're migrating from 1.1 to 1.3 - we have a directory

myapp/
    templatetags/
        tagmodule/
            __init__.py
            foo.py

This worked fine in 1.1 with {% load tagmodule.foo %} in the template. In 1.3 this breaks. In django.template.base.get_library loops through templatetag_modules pairing modules and libraries and calling import_library. On line 951 of base.py:

app_path, taglib = taglib_module.rsplit('.',1)
app_module = import_module(app_path)

That rsplit left my "tagmodule" in the app_path, which then failed to import as it was paired with another path.

Reorganizing my templatetags under deadline, just wanted to mention it.

Change History (3)

comment:1 Changed 6 years ago by anonymous

Component: UncategorizedTemplate system
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 6 years ago by Julien Phalip

Owner: changed from nobody to Julien Phalip
Triage Stage: UnreviewedAccepted

I confirm that this regression was introduced in [12944]. I'll try to work on a patch.

comment:3 Changed 6 years ago by Julien Phalip

Resolution: wontfix
Status: newclosed

On a second thought, I'm not sure we should allow this. If your concern is to break large templatetag libraries into multiple files, then you still can do it by doing "from foo import *" in the main module's __init__.py file. If you have a more compelling reason for allowing this behaviour, then please reopen with more details.

Note: See TracTickets for help on using tickets.
Back to Top