bathroom_singer
bathroom_singer

Reputation: 13

Django URLs NoReverseMatch

I've been trying to figure this out, but can't seem to catch my error.

In my Django 1.6 project I have two apps: hold and control

Project urls.py

url(r'^control/$', include('control.urls')),

App control/urls.py

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

#this doesn't work
url(r'^invite/$', views.control_invite, name='control_invite'),

Control views.py

def index(request):
    return render(request, 'control_index.html')


def control_invite(request):
    return render(request, 'control_invite.html')

Template control_index.html

<li class="active"><a href="{% url 'control_home' %}">Control</a></li>
<li><a href="{% url 'control_invite' %}">Invitations</a></li>

Error

Reverse for 'control_invite' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['control/$invite/$']

I get the same error in the shell. Not sure what I'm missing...

Upvotes: 1

Views: 472

Answers (2)

yuvi
yuvi

Reputation: 18427

You have a $ sign at the end of your main urls.py which means the pattern should end at control/ and not allow any more sub-urls. Change it to this:

url(r'^control/', include('control.urls')),

Upvotes: 3

Aamir Rind
Aamir Rind

Reputation: 39659

Project urls.py should be:

url(r'^control/', include('control.urls')),

There is no need for $ (it means nothing comes after that).

Upvotes: 1

Related Questions