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.
* cc: daniel.samuels1@… (added)
* needs_better_patch: => 0
* component: Uncategorized => Utilities
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
--
Ticket URL: <https://code.djangoproject.com/ticket/25570#comment:1>
Comment (by timgraham):
The documentation [https://docs.djangoproject.com/en/1.8/ref/django-admin
/#render-warning warns about this]. I'm not sure it can/should be fixed as
it seems to me we cannot treat some part of the file as a template but not
others.
--
Ticket URL: <https://code.djangoproject.com/ticket/25570#comment:2>
* status: new => closed
* resolution: => wontfix
--
Ticket URL: <https://code.djangoproject.com/ticket/25570#comment:3>