Code

Opened 3 years ago

Closed 3 years ago

#15680 closed (wontfix)

templatetags submodules no longer work

Reported by: EMiller Owned by: julien
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.

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by anonymous

  • Component changed from Uncategorized to Template system
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by julien

  • Owner changed from nobody to julien
  • Triage Stage changed from Unreviewed to Accepted

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

comment:3 Changed 3 years ago by julien

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

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.

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.