这是一个奇怪(对我来说)的调试问题。我有一个包含三个应用程序的Django 2.0应用程序-app1,app2和app3。 app1以及app2和app3都在很久以前就工作了。此时,我仅对所有三个应用程序使用管理界面。我在app3中做了一些工作来优化一些代码。我完成了这一步,并在app1上进行了一些快速测试,然后它崩溃了。我可以访问app1中所有模型的主管理页面,但是当我单击更改页面时出现此错误
Template error:
In template /home/mark/python-projects/memorabilia-JSON/memorabilia/templates/admin/memorabilia/change_form.html, error at line 14
Could not parse the remainder: '>' from ''</table'>'
4 :
5 : {% for fieldset in adminform %}
6 : {% cycle '<table border=0 width=100%>' ' ' %}
7 : {% cycle '<tr>' ' ' %}
8 : {% cycle '<td width =50%’ ‘td width =50%>' ' ' %}
9 :
10 : {% include "admin/includes/fieldset.html" %}
11 :
12 : {% cycle '</td>' '</td>' ' ' %}
13 : {% cycle '</tr>' ' '%}
14 : {% cycle '</table'> ' ' %}
15 :
16 : {% endfor %}
17 : {% endblock %}
18 :
19 :
Traceback:
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
158. response = self.process_exception_by_middleware(e, request)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
156. response = response.render()
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/response.py" in render
106. self.content = self.rendered_content
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/response.py" in rendered_content
81. template = self.resolve_template(self.template_name)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/response.py" in resolve_template
63. return select_template(template, using=self.using)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/loader.py" in select_template
42. return engine.get_template(template_name)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/backends/django.py" in get_template
34. return Template(self.engine.get_template(template_name), self)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/engine.py" in get_template
144. template, origin = self.find_template(template_name)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/engine.py" in find_template
126. template = loader.get_template(name, skip=skip)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/loaders/base.py" in get_template
30. contents, origin, origin.template_name, self.engine,
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in __init__
160. self.nodelist = self.compile_nodelist()
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in compile_nodelist
198. return parser.parse()
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
483. raise self.error(token, e)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
481. compiled_result = compile_func(self, token)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/loader_tags.py" in do_extends
290. nodelist = parser.parse()
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
483. raise self.error(token, e)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
481. compiled_result = compile_func(self, token)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/loader_tags.py" in do_block
233. nodelist = parser.parse(('endblock',))
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
483. raise self.error(token, e)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
481. compiled_result = compile_func(self, token)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/defaulttags.py" in do_for
815. nodelist_loop = parser.parse(('empty', 'endfor',))
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
483. raise self.error(token, e)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in parse
481. compiled_result = compile_func(self, token)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/defaulttags.py" in cycle
628. values = [parser.compile_filter(arg) for arg in args[1:]]
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/defaulttags.py" in <listcomp>
628. values = [parser.compile_filter(arg) for arg in args[1:]]
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in compile_filter
568. return FilterExpression(token, self)
File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/template/base.py" in __init__
668. "from '%s'" % (token[upto:], token))
Exception Type: TemplateSyntaxError at /admin/memorabilia/collection/1/change/
Exception Value: Could not parse the remainder: '>' from ''</table'>'
app2和app3的管理页面都没有此错误-它们工作正常。我从未接触过任何应用程序的管理模板。我尝试在admin.py和早期版本的app1的所有.py文件之间进行比较,并且没有区别。我还查看了与早期版本的app2和app3的.py文件中的差异,唯一的更改是我所做的更改,当我为这些应用程序中的模型使用管理员更改表单时,它们都没有引发错误。
由于该错误来自Django代码,我对如何查找此错误的来源一无所知。任何建议将不胜感激!
标记
答案 0 :(得分:1)
该错误在您的模板中。您在错误的地方引用了报价:
14 : {% cycle '</table'> ' ' %}
应该是:
14 : {% cycle '</table>' ' ' %}
根据追溯,它位于memorabilia-JSON/memorabilia/templates/admin/memorabilia/change_form.html
中。