Ze carlos
Ze carlos

Reputation: 19

Django Url regex NoReverseMatch error

Have this html, that i want to pass 2 arguments to a function when that url is pressed:

htmlpage

{% for n in notifications %}
                    <li style="..."><b>{{ n.title }}</b> - {{ n.description }}
                    <a href="{% url 'update-notify-status' n.id n.title %}" >Don't show again</a>
{% endfor %}

urls.py

url(r'^notification_htmlv2/update_status/([0-9]{4})/([0-9]{4})$', 'Notifications.views.updateStatus',
                       name="update-notify-status"),

views.py

def updateStatus(request,noteId,noteTile):
q=History.objects.filter(notification_id=noteId,title=noteTile).order_by('-id')[0]

When i start the program it gives an error of "NoReverseMatch". Im following this example:https://docs.djangoproject.com/en/1.8/topics/http/urls/

reverse resolution of url's chapter

Upvotes: 1

Views: 193

Answers (1)

aumo
aumo

Reputation: 5554

I bet neither n.id nor n.title matches ([0-9]{4}).

You should update your url pattern to handle any possible id and title values.

Something like:

r'^notification_htmlv2/update_status/([0-9]+)/([a-zA-Z0-9]+)$'

Upvotes: 1

Related Questions