0

I followed the Django tutorial on how to use the url dispatcher, but for the life of me cannot figure out why I am getting this error.

Reverse for 'details' with arguments '('my_address',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['details(?P[0-9]+)/$']

My url.py:

url(r'^details(?P<zip>[0-9]+)/$', views.search_details, name='details'),

The url used in my template:

<h1><a href="{% url 'details' data.zip%}">Data for {{data.zip}}</a></h1>

My view method declaration:

def search_details(request,zip):

When I try remove the parameter(zip) from the above code, the template renders, so I would believe the url is correct.

2 Answers 2

2

Your zip parameter matches digits from 0 to 9. The string "my_address" is not made up of those digits.

You should either pass a real zip, assuming those actually are numeric rather than alphabetic, or use a different pattern such as \w+.

Sign up to request clarification or add additional context in comments.

1 Comment

You are a godsend! Thank you so much, I'll accept when able!
0

I think your missing / after details:

url(r'^details/(?P<zip>[0-9]+)/$', views.search_details, name='details'),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.