Question

I'm trying to set up django-openid-auth on my django project. I've followed steps 1-8 of the provided guide and have tried going to /openid/login/ on my server. 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.
Was it helpful?

Solution

Since you are using 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" %}. If you were using {% load url from future %} you can simply remove that line under Django 1.5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top