Code

#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: master
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.

Attachments (0)

Change History (1)

comment:1 Changed 21 months ago by lrekucki

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

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.