如何解决TemplateSyntaxError:无法解析余数错误? [英] How to resolve TemplateSyntaxError: Could not parse the remainder error?

查看:256
本文介绍了如何解决TemplateSyntaxError:无法解析余数错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了 TemplateSyntaxError:无法解析其余部分: 此处: https://docs.djangoproject.com/en /1.7/intro/tutorial05 /

>>> response = client.get(reverse('polls:index'))

给我这个:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 470, in get
    **extra)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 286, in get
    return self.generic('GET', path, secure=secure, **r)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 358, in generic
    return self.request(**r)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 440, in request
    six.reraise(*exc_info)
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
    response = response.render()
  File "/Library/Python/2.7/site-packages/django/template/response.py", line 103, in render
    self.content = self.rendered_content
  File "/Library/Python/2.7/site-packages/django/template/response.py", line 78, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/Library/Python/2.7/site-packages/django/template/response.py", line 54, in resolve_template
    return loader.select_template(template)
  File "/Library/Python/2.7/site-packages/django/template/loader.py", line 188, in select_template
    return get_template(template_name, dirs)
  File "/Library/Python/2.7/site-packages/django/template/loader.py", line 144, in get_template
    template, origin = find_template(template_name, dirs)
  File "/Library/Python/2.7/site-packages/django/template/loader.py", line 132, in find_template
    source, display_name = loader(name, dirs)
  File "/Library/Python/2.7/site-packages/django/template/loader.py", line 44, in __call__
    return self.load_template(template_name, template_dirs)
  File "/Library/Python/2.7/site-packages/django/template/loader.py", line 50, in load_template
    template = get_template_from_string(source, origin, template_name)
  File "/Library/Python/2.7/site-packages/django/template/loader.py", line 156, in get_template_from_string
    return Template(source, origin, name)
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 132, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 162, in compile_string
    return parser.parse()
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 290, in parse
    compiled_result = compile_func(self, token)
  File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 975, in do_if
    nodelist = parser.parse(('elif', 'else', 'endif'))
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 290, in parse
    compiled_result = compile_func(self, token)
  File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 833, in do_for
    nodelist_loop = parser.parse(('empty', 'endfor',))
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 290, in parse
    compiled_result = compile_func(self, token)
  File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 1345, in url
    viewname = parser.compile_filter(bits[1])
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 372, in compile_filter
    return FilterExpression(token, self)
  File "/Library/Python/2.7/site-packages/django/template/base.py", line 588, in __init__
    "from '%s'" % (token[upto:], token))
TemplateSyntaxError: Could not parse the remainder: '\u2018polls:detail\u2019' from '\u2018polls:detail\u2019'

如何解决此问题?

推荐答案

您正在使用左引号右引号引用视图名称时的字符;

You are using left quote and right quote characters when quoting the view name; where you should be using single or double quotes.

使用'polls:details'民意调查:详细信息

这篇关于如何解决TemplateSyntaxError:无法解析余数错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆