[Fixed]-Url template tag in django template

13👍

IMPORTANT: this was for django 1.4. At django 1.5 it is just the opposite.

try using url names without quotes

{% url show %}

not this

{% url 'show'%}

10👍

The problem is your single quotes around ‘show’. Change this to “show” and it should work out for you.

See here

3👍

You maybe have some views not implemented yet. It looks like the template engine tries to find all views from the patterns in urls.py when the {% url … %} filter is used.

It usually shows an error for your last pattern in urls.py.

Try comment out every url pattern you did not implement yet.

Also make sure you use the full path:

{% url myapp.views.home %}

The url template filter looks really unstable. Try to keep future compatibility.

1👍

You may need to be a little more specific on which view you’re trying to use:

{% url appname.views.show %}

0👍

For what is is worth, I had the same issue and while I do not remember the reason why now, this resolved it for me. Example from a SCRUM app I was working on.

url(r'^$', 'scrum.views.index',  name='scrum-index'),

0👍

Django 1.5 or above:

{% url 'show'%}

Django 1.4 or below:

{% url show %}

*You can see Django 1.5 release notes.

Leave a comment