dekuked
dekuked

Reputation: 1

Django url template confusion

Okay I am having a bit of an issue.

I want to create a button with a link, and right now I am using action={% url views.contest_overview %} in hopes that the reverse lookup by Django will match (r'^category/$', views.contest_overview), in my urls.py. However, this is not working and I can't figure out the proper nomenclature, despite numerous guesses.

The error I get (with my best guess above) is:

Caught NoReverseMatch while rendering: Reverse for 'views.contest_overview' with arguments '()' and keyword arguments '{}' not found.

Thank you very much for your time!

Upvotes: 0

Views: 170

Answers (2)

Vannen
Vannen

Reputation: 752

This is what I usually do; I give names to my url. For example:

url(r'^account/register/$', 'someapp.views.register_view', name='account_register'),

Therefore in template, I can do this:

{% url account_register as url_acc_register %}
<html>
..
..
<a href="{{ url_acc_register }}">Some link </a>

Upvotes: 0

Raekkeri
Raekkeri

Reputation: 761

Use the application name in the url tag, e.g. {% url myapp.views.contest_overview %}

Upvotes: 2

Related Questions