#25570: Using a templatetag in a Python file in a project template causes an
Exception
-------------------------------+--------------------
Reporter: danielsamuels | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
If you have a Python file in your project template and you have a string
of code such as {{{ {% static %} }}}, startproject will throw an exception
as it tries to render the tag.
As a minimum viable test case, I put together the following repository:
https://github.com/danielsamuels/django-project-template-bug
It consists of a single {{{ __init__.py }}} with a comment inside, the
contents of the comment being {{{ {% static %} }}}. Using this as a
project template will cause the following exception to be thrown:
{{{ django-admin startproject output --template
https://github.com/danielsamuels/django-project-template-
bug/archive/master.zip }}}
{{{
Traceback (most recent call last):
File "/Users/danielsamuels/Workspace/testing/.venv/bin/django-admin",
line 11, in <module>
sys.exit(execute_from_command_line())
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/core/management/__init__.py", line 351, in
execute_from_command_line
utility.execute()
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/core/management/commands/startproject.py", line 33, in
handle
super(Command, self).handle('project', project_name, target,
**options)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/core/management/templates.py", line 151, in handle
template = Engine().from_string(content)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/template/engine.py", line 153, in from_string
return Template(template_code, engine=self)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/template/base.py", line 190, in __init__
self.nodelist = engine.compile_string(template_string, origin)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/template/engine.py", line 261, in compile_string
return parser.parse()
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/template/base.py", line 339, in parse
self.invalid_block_tag(token, command, parse_until)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-
packages/django/template/base.py", line 395, in invalid_block_tag
raise self.error(token, "Invalid block tag: '%s'" % command)
django.template.base.TemplateSyntaxError: Invalid block tag: 'static'
}}}
In theory, this project template _should_ work, given that the templatetag
is just a comment within the project.
--
Ticket URL: <https://code.djangoproject.com/ticket/25570>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.b8802dd13c7111e10d0ced98ca2b77e1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.