我正在尝试学习如何使用 cookiecutter 并创建了我自己的基于 django 的项目,其中包含一些引用 .js、.map 文件的静态 jinja2 模板。
我已经从一个在运行时成功显示 webapp 的工作本地项目创建并调整了它python manage.py runserver
。
但是,当我尝试运行我的 cookie 项目时,我会得到一个jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got ':'
第三方js.min.js.map
文件,如下所示:
就好像 cookiecutter 正在尝试解析地图文件?cookiecutter 不应该将静态文件复制到新项目中吗?我该如何调试为什么会这样?
当我尝试使用我的千篇一律的项目时出现错误
$ cookiecutter my-cookiecutter-project
description [desc]: desc
email [me@example.com]:
full_name [Your Name]: me
license [MIT]:
project_name [default_project]: myproj
python_version [3.8]:
Traceback (most recent call last):
File "/Users/simon/Library/Python/3.8/bin/cookiecutter", line 8, in <module>
sys.exit(main())
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/cookiecutter/cli.py", line 140, in main
cookiecutter(
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/cookiecutter/main.py", line 101, in cookiecutter
result = generate_files(
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/cookiecutter/generate.py", line 352, in generate_files
generate_file(
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/cookiecutter/generate.py", line 169, in generate_file
tmpl = env.get_template(infile_fwd_slashes)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/jinja2/environment.py", line 997, in get_template
return self._load_template(name, globals)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/jinja2/environment.py", line 958, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/jinja2/loaders.py", line 137, in load
code = environment.compile(source, name, filename)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/jinja2/environment.py", line 757, in compile
self.handle_exception(source=source_hint)
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "./{{ cookiecutter.project_name }}/local/api/static/assets/plugins/chartist-js/dist/chartist.min.js.map", line 1, in template
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got ':'