Django

Code

Ticket #5243 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

{% load %} does not load template tags inside sub-directories

Reported by: Bjørn Stabell <bjorn@exoweb.net> Assigned to: nobody
Milestone: Component: Template system
Version: SVN Keywords: load
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by adrian)

According to {% load %} you can load templatetags that are in subdirectories, e.g. {% load news.blah %}. This didn't work for me; I kept getting errors.

Applying the below patch seems to work. I don't know why taglib.split('.')[-1]) was done in the first place? It's been like this for as far back as I could trace the revisions in on this Trac. A related ticket might be #372.

Index: django/template/defaulttags.py
===================================================================
--- django/template/defaulttags.py      (revision 8271)
+++ django/template/defaulttags.py      (working copy)
@@ -792,7 +792,7 @@
     for taglib in bits[1:]:
         # add the library to the parser
         try:
-            lib = get_library("django.templatetags.%s" % taglib.split('.')[-1])
+            lib = get_library("django.templatetags.%s" % taglib)
             parser.add_library(lib)
         except InvalidTemplateLibrary, e:
             raise TemplateSyntaxError, "'%s' is not a valid tag library: %s" % (taglib, e)

Attachments

defaulttags.patch (0.6 kB) - added by Bjørn Stabell <bjorn@exoweb.net> on 08/24/07 07:07:27.
Patch to make {% load module.submodule %} work

Change History

08/24/07 07:07:27 changed by Bjørn Stabell <bjorn@exoweb.net>

  • attachment defaulttags.patch added.

Patch to make {% load module.submodule %} work

08/25/07 13:30:10 changed by adrian

  • needs_better_patch changed.
  • description changed.
  • needs_tests changed.
  • needs_docs changed.

Fixed formatting in description.

08/29/07 07:59:38 changed by Simon G. <dev@simon.net.nz>

  • has_patch set to 1.
  • summary changed from Bug in {% load %} to {% load %} does not load template tags inside sub-directories.
  • stage changed from Unreviewed to Ready for checkin.

09/15/07 10:57:17 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6289]) Fixed #5243 -- Allow loading of templatetags from subdirectories (via dotted notation in {% load %}). Thanks, Bj?\195?\184rn Stabell.

09/19/07 21:04:23 changed by lex.forget@gmail.com

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

For me this patch broke the loading in subdirectories

I am using nesh.thumbnail

in the template: {% load nesh.thumbnail %}

in the settings: {{{INSTALLED_APPS = (

'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.markup', 'django.contrib.flatpages', 'django.contrib.humanize', 'nesh.thumbnail',

)

}}}

09/19/07 21:18:32 changed by brosner

  • status changed from reopened to closed.
  • resolution set to fixed.

This change was a backward incompatible change. Please see http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Templatetagloadingrespectsdottednotation for more information. Please take this to django-users or #django on freenode.


Add/Change #5243 ({% load %} does not load template tags inside sub-directories)




Change Properties
Action