Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

1,005 views
Skip to first unread message

Loai Ghoraba

unread,
Dec 3, 2012, 7:31:35 AM12/3/12
to django...@googlegroups.com
Hi

I have this in my urls.py

    url(r'^accounts/login/$', login,name="accounts-login")

and in a template base.html
 <a href="{%url accounts-login%}?next=/somelink/">login</a>

And when I try to open the site, this error is raised: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'

But when I change the name of the url in both urls.py and base.html to something without the score '-', it works: like :accountslogin.

So are scores banned in named urls ? I have seen scored-named-urls in the documentation !

Thanks in advance.


Nikhil Verma

unread,
Dec 3, 2012, 7:34:21 AM12/3/12
to django...@googlegroups.com
Try <a href="{% url auth_login %}?next=/somelink">Sign in



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/g19mRQ4vHd4J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Regards
Nikhil Verma
+91-958-273-3156

Loai Ghoraba

unread,
Dec 3, 2012, 7:50:29 AM12/3/12
to django...@googlegroups.com
not working, giving: Reverse for '' with arguments '()' and keyword arguments '{}' not found.

also I want to know about this dash (sorry for using the term score in the previous post ) thing

On Mon, Dec 3, 2012 at 2:34 PM, Nikhil Verma <varma.n...@gmail.com> wrote:
{% url auth_login %}


Loai Ghoraba

unread,
Dec 3, 2012, 7:54:19 AM12/3/12
to django...@googlegroups.com
okay I found it:

it should be  <a href="{%url "accounts-login"%}?next=/somelink/">login</a> with quotes. Thanks.

Larry Martell

unread,
Dec 3, 2012, 7:55:19 AM12/3/12
to django...@googlegroups.com
Hyphens are valid in urls, but not in python. A hyphen is an operator
in python (subtraction operator), so you cannot use it in django.

donarb

unread,
Dec 3, 2012, 12:51:23 PM12/3/12
to django...@googlegroups.com
Except, the Django documentation states that url names with dashes are acceptable and the examples show url tags using unquoted names. It even says you can use any character you want:

The string used for the URL name can contain any characters you like. You are not restricted to valid Python names.

donarb

unread,
Dec 3, 2012, 12:56:59 PM12/3/12
to django...@googlegroups.com
Correction, the syntax has changed between 1.4 and 1.5. You are now required to quote the name in the url tag.

Reply all
Reply to author
Forward
0 new messages