I do not know how I missed that. I did read the documentation, but 
obviously not very thoroughly.

Thank you very much for the help. I shall be more careful in the future.

On Sunday, January 20, 2013 4:40:46 AM UTC+11, Daniel Roseman wrote:
>
> On Saturday, 19 January 2013 13:15:42 UTC, robzyb wrote:
>
>> Hi Everyone
>>
>> I have the following in my project's urls.py (watch_detail is a 
>> dictionary with some parameters):
>>
>> urlpatterns = patterns('',
>>> url(r'^watches/(?P<object_id>\d+)/$', list_detail.object_detail, 
>>> watch_detail, name='watch_detail'),
>>>  )
>>
>>
>> However, the following line in a template returns an error:
>>
>> <li><a href ="{% url 'watch_detail' 1 %}">A link</a></li>
>>
>>
>> The error is this:
>>
>> NoReverseMatch at /watches/
>>
>> Reverse for ''watch_detail'' with arguments '(1,)' and keyword arguments 
>>> '{}' not found.
>>
>>
>> I really would have expected that template code to work. Because the 
>> following works in "manage.py shell":
>>
>> >>> from django.core.urlresolvers import reverse
>>> >>> reverse("watch_detail", args=(1,))
>>> '/watches/1/'
>>> >>>
>>
>>
>> I've done a whole lot of Google'ing, but I can't seem to figure out why 
>> it works in the shell, but doesn't work in the template.
>>
>> Does anyone have any suggestions?
>>
>> Thank you. 
>>
>
> Look closely at the error message. There are *two* single quotes around 
> watch_detail. That's because you're (probably) using the current release, 
> 1.4, rather than the development version, where the syntax is not to use 
> quotes around the view name in the url tag:
>
>     {% url watch_detail 1 %}
>
> Note this is fully explained in both the 1.4 and dev documentation:
> https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
> --
> DR.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Apsh1o1vYhQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to