Django

Code

Ticket #12772 (reopened)

Opened 1 month ago

Last modified 4 weeks ago

Allow loading template tags by fully qualified python module path

Reported by: patrys Assigned to: nobody
Milestone: Component: Template system
Version: 1.2-beta Keywords:
Cc: paluho@gmail.com, ramusus@gmail.com, brian@unbracketed.com Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Currently templatetags are magically searched for in the list of installed apps. This leads to all kind of problems when debugging code, starting from being forced to use find to locate tag libraries and ending with global namespace collisions.

The attached patch adds the possibility to import tags by fully qualified module path by first trying to make an absolute import and only then falling back to searching inside installed apps.

This also allows people to import tag libraries that are not parts of any application (so common tags can be kept together without the need of adding a fake app).

Also: "Explicit is better than implicit." :)

Attachments

django-fully-qualified-template-tags.patch (1.5 kB) - added by patrys on 02/04/10 06:19:21.
Proposed change

Change History

02/04/10 06:19:21 changed by patrys

  • attachment django-fully-qualified-template-tags.patch added.

Proposed change

02/04/10 06:44:45 changed by emulbreh

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

Duplicate of #2539.

(follow-up: ↓ 3 ) 02/04/10 07:01:58 changed by patrys

  • status changed from closed to reopened.
  • resolution deleted.

It's not a duplicate.

#2539 is adding even more magic to the template loader.

My proposal here is removing the magic and eventually deprecating the old syntax. The "templatetags" dir should not be magic.

(in reply to: ↑ 2 ) 02/04/10 07:16:26 changed by emulbreh

Replying to patrys:

It's not a duplicate. #2539 is adding even more magic to the template loader. My proposal here is removing the magic and eventually deprecating the old syntax. The "templatetags" dir should not be magic.

Personally, I like your proposal better (one should get rid of app_label and flat namespaces everywhere). But since #2539 is also about adding some kind of namespace support to template libraries, it makes sense to have a single ticket.

02/04/10 13:32:36 changed by ramusus

  • cc set to ramusus@gmail.com.

02/04/10 23:34:03 changed by Alex

  • stage changed from Unreviewed to Design decision needed.

02/05/10 05:19:44 changed by paluh

  • cc changed from ramusus@gmail.com to paluho@gmail.com.

02/05/10 05:20:14 changed by paluh

  • cc changed from paluho@gmail.com to paluho@gmail.com, ramusus@gmail.com.

02/16/10 21:15:25 changed by unbracketed

  • cc changed from paluho@gmail.com, ramusus@gmail.com to paluho@gmail.com, ramusus@gmail.com, brian@unbracketed.com.

Add/Change #12772 (Allow loading template tags by fully qualified python module path)




Change Properties
Action