Django Template Error – Reverse Template Not Found

Running into a strange django error:

“Reverse for ” with arguments ‘()’ and keyword arguments ‘{}’ not found. ”

This error appeared mysteriously when porting a working project from one computer to another. The first computer was running Python 2.7.1, the second – Python 2.7.2. All other project settings were identical.

For the original computer (Python 2.7.1), the following settings:
base.html:

<a href="{% url 'display_rulelist' %}"><span class="numbertxt"> Rule List </span>

urls.py:

url(r'^rulelist/$', rulelist.views.display_rulelist,  name = 'display_rulelist')

worked correctly, with no errors. These did NOT work for Python 2.7.2!

For the new computer (Python 2.7.2),
base.html:

<a href="{% url display_rulelist %}"><span class="numbertxt"> Rule List </span>

removing the apostrophes solved the problem.

I tried going back to the first version and removing the apostrophes as well, but after making the change – the first project no longer worked.

All I can recommend: when running into this error, try both versions!

EDITED:

It was pointed out to me (see comments below) that the url formatting was updated between django 1.4.x and django 1.5. I had completely overlooked that the django versions were different, but so they were: the first project had run django 1.5, and the second: django 1.4.3. Beware of old django versions, users-who-work-on-more than one computer! BEWAAAARE!

Advertisements

2 Responses

  1. The url syntax changed between django 1.4.x and 1.5
    https://docs.djangoproject.com/en/dev/topics/http/urls/

    • O_o you’re right!
      I had a previous version of django (1.4.3) installed on the second computer which hadn’t been used for some months, and I completely forgot about it… the new project in 1.5. Thanks!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: