Opened 12 years ago

Closed 12 years ago

#19169 closed Uncategorized (invalid)

tag_function() uses name of decorated function wich in python 3.3 in lower case but python 3.2 in same case as function name

Reported by: alex_po Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords: tag
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I got an error: Invalid block tag: 'addtoblock', expected 'endblock'. While i have properly installed sekizai. When i tried to debug i found that tag_function() (django/template/base.py line 1064) uses a name of decorated function for adding a template tag in tags dict. But sekizai uses name for decorated function with CamelCase for instance Addtoblock. In result the tag name is 'Addtoblock'.
The stranges are that in python 3.2 the name of decorated function is such as a name of class but in python 3.3 the name of decorated function is in lowercase. In result all works well for python 3.3 (template tag is 'addtoblock') but there is error (invalid block tag. template tag is 'Addtoblock') for python 3.2.

Change History (1)

comment:1 by Łukasz Rekucki, 12 years ago

Resolution: invalid
Status: newclosed

Django uses __name__ of whatever callable you give it. It looks like django-classy-tags is hacking on a non-public API by injecting _decorated_function in a metaclass. This works for me both on 3.2 and 3.3, with the django-classy-tags at this revision: https://github.com/ojii/django-sekizai/commit/49e28d9111a8932de1f86d14e6c75fcc316197e2. Make sure you have the same version of that library on both of your python versions.

Either way, this isn't a bug in Django itself.

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