Django:TemplateSyntaxError:无法解析其余部分 [英] Django: TemplateSyntaxError: Could not parse the remainder

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

问题描述

键入localhost:8000/admin/时出现此问题.

`TemplateSyntaxError:无法解析'admin:password_change'中的剩余部分:':password_change'. "url"的语法在Django 1.5中已更改,请参阅文档.

`TemplateSyntaxError: Could not parse the remainder: ':password_change' from 'admin:password_change'. The syntax of 'url' changed in Django 1.5, see the docs.

这是我settings.py的一部分:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'grappelli',
    'filebrowser',
    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    #'django.contrib.admindocs',
     'tinymce',
     'sorl.thumbnail',
     'south',
     'django_facebook',
     'djcelery',
     'devserver',
     'main',
)
AUTH_USER_MODEL = 'django_facebook.FacebookCustomUser'

AUTHENTICATION_BACKENDS = (
    'django_facebook.auth_backends.FacebookBackend', 
    'django.contrib.auth.backends.ModelBackend',
    # Uncomment the following to make Django tests pass:
    'django.contrib.auth.backends.ModelBackend',
)

我做错了什么吗?

PS:这是我的完整回溯 https://gist.github.com/anonymous/e8c1359d384df7a6b405

PS: This is my full traceback https://gist.github.com/anonymous/e8c1359d384df7a6b405

我正在按照请求粘贴grep的输出:

I am pasting the output of grep as per request:

$ ack-grep --type=python -r ':password_change' .
lib/python2.7/site-packages/django/contrib/admin/sites.py
264:url = reverse('admin:password_change_done', current_app=self.name)

lib/python2.7/site-packages/grappelli/dashboard/dashboards.py
147:reverse('%s:password_change' % site_name)],

$ ack-grep --type=html -r ':password_change' .
lib/python2.7/site-packages/django/contrib/admin/templates/admin/base.html
36:<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /

lib/python2.7/site-packages/grappelli/templates/admin/includes_grappelli/header.html
12:{% url admin:password_change as password_change_url %} 

推荐答案

此错误通常表示您忘记了要呈现的模板中某个地方的右引号.例如:{% url 'my_view %}(错误)而不是{% url 'my_view' %}(正确).在这种情况下,是引起问题的冒号.通常,您将编辑模板以使用正确的{% url %} 语法.

This error usually means you've forgotten a closing quote somewhere in the template you're trying to render. For example: {% url 'my_view %} (wrong) instead of {% url 'my_view' %} (correct). In this case it's the colon that's causing the problem. Normally you'd edit the template to use the correct {% url %} syntax.

但是django管理站点没有理由抛出该错误,因为它知道它是自己的语法.因此,我最好的猜测是grapelli引起了您的问题,因为它更改了管理模板.从已安装的应用程序中删除grappelli是否有帮助?

But there's no reason why the django admin site would throw this, since it would know it's own syntax. My best guess is therefore that grapelli is causing your problem since it changes the admin templates. Does removing grappelli from installed apps help?

这篇关于Django:TemplateSyntaxError:无法解析其余部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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