简体   繁体   中英

How to resolve TemplateSyntaxError: Could not parse the remainder error?

I'm getting a "TemplateSyntaxError: Could not parse the remainder:" here: https://docs.djangoproject.com/en/1.7/intro/tutorial05/

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

gets me this:

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'

How to resolve this ?

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

Use either 'polls:details' or "polls:details"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM