I am new to Django and have started working on a mature Django project.
I want to add a new page to the user account screens, and link to it. But I am getting a NoReverseMatch error.
To /users/urls.py I added:
url(r'^panel/history$',
'theproject.users.views.history',
name='account_history'
),
…which is consistent with the line above it:
url(r'^panel$',
'theproject.users.views.control_panel',
name='account_panel'
),
To /users/views.py I added:
@login_required
def history(request):
return render_to_response('users/ourbrand_history.html', {},
context_instance=RequestContext(request))
…which is consistent with the line above it:
@login_required
def control_panel(request):
return render_to_response('users/ourbrand_panel.html', {},
context_instance=RequestContext(request))
To /templates/users/ourbrand_panel.html I added:
<a href="{% url account_history %}">History</a>
…which is consistent with the line above it:
<a href="{% url account_panel %}">Home</a>
Now when I load /panel I get a TemplateSyntaxError: NoReverseMatch.
Reverse for 'account_history' with arguments '()' and keyword arguments '{}' not found.
UPDATE: As a test, I removed my link in the template — and /panel loads fine. If I then delete /users/urls.py and /users/views.py /panel still loads. I have deleted all cookies, history etc. Do I have to run a command at the terminal (like rake in ruby) to commit changes to urls.py? Or should changes ‘just work’?
Answering my own question (based on help provided here)…
Since the server is production, changes to
urls.pydo not have any effect until the server is restarted. Currently I do not havesuaccess so cannotapachectl restartbut it appears this will resolve the issue.