简体   繁体   English

django-openid-auth:TemplateSyntaxError

[英]django-openid-auth: TemplateSyntaxError

I'm trying to set up django-openid-auth on my django project. 我正在尝试在我的django项目上设置django-openid-auth I've followed steps 1-8 of the provided guide and have tried going to /openid/login/ on my server. 我已按照提供的指南中的步骤1-8进行操作,并尝试转到服务器上的/openid/login/ However, when I go to that page I see 但是,当我转到该页面时,我看到

TemplateSyntaxError at /openid/login/
Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.

I'm a bit confused since this is in a template included in the app - I didn't write the template myself. 我有点困惑,因为它位于应用程序中包含的模板中-我不是自己编写模板的。 If anybody knows what I'm doing wrong, I'd really appreciate some help. 如果有人知道我在做什么错,我将非常感谢您的帮助。

Here's my stacktrace: 这是我的堆栈跟踪:

Environment:


Request Method: GET
Request URL: http://localhost:8000/openid/login/

Django Version: 1.5.2
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'wseeruploader.apps.fileupload',
 'django_openid_auth',
 'crispy_forms')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Template error:
In template /usr/lib/python2.7/site-packages/django_openid_auth/templates/openid/login.html, error at line 8
   Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.
   1 : {% load i18n %}


   2 : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">


   3 : <html>


   4 : <head>


   5 : <title>Sign in with your OpenID</title>


   6 : <style type="text/css">


   7 : input.openid {


   8 :     background: url( {% url openid-logo %} ) no-repeat;


   9 :     background-position: 0 50%;


   10 :     padding-left: 16px;


   11 : }


   12 : </style>


   13 : </head>


   14 : <body>


   15 : <h1>Sign in with your OpenID</h1>


   16 : {% if form.errors %}


   17 : <p class="errors">{% trans "Please correct errors below:" %}<br />


   18 :     {% if form.openid_identifier.errors %}


Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django_openid_auth/views.py" in login_begin
  171.                     }, context_instance=RequestContext(request))
File "/usr/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
  29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  170.         t = get_template(template_name)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in get_template
  146.     template, origin = find_template(template_name)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in find_template
  135.             source, display_name = loader(name, dirs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in __call__
  43.         return self.load_template(template_name, template_dirs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in load_template
  49.             template = get_template_from_string(source, origin, template_name)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in get_template_from_string
  157.     return Template(source, origin, name)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in __init__
  125.         self.nodelist = compile_string(template_string, origin)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in compile_string
  153.     return parser.parse()
File "/usr/lib/python2.7/site-packages/django/template/base.py" in parse
  274.                     compiled_result = compile_func(self, token)
File "/usr/lib/python2.7/site-packages/django/template/defaulttags.py" in url
  1266.         viewname = parser.compile_filter(bits[1])
File "/usr/lib/python2.7/site-packages/django/template/base.py" in compile_filter
  353.         return FilterExpression(token, self)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in __init__
  570.                                       "from '%s'" % (token[upto:], token))

Exception Type: TemplateSyntaxError at /openid/login/
Exception Value: Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.

Since you are using django-1.5 由于您正在使用django-1.5

You should change: 您应该更改:

{% url openid-logo %} 

to

{% url 'openid-logo' %} 

Relevant documentation can be found in the release notes 相关文档可以在发行说明中找到

The upshot of this is that if you are not using {% load url from future %} in your templates, you'll need to change tags like {% url myview %} to {% url "myview" %}. 这样做的结果是,如果您在模板中未使用{%将来的%}加载URL,则需要将{%url myview%}之类的标签更改为{%url“ myview”%}。 If you were using {% load url from future %} you can simply remove that line under Django 1.5 如果您使用的是{未来的%加载网址},则可以在Django 1.5下简单地删除该行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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