Thanks for your response!

Unfortunately, your suggestion did not eliminate the NoReverseMatch error.

NoReverseMatch at /testadcall/

Reverse for 'detail' with arguments '()' and keyword arguments
'{'object_id': 1}' not found.


I have another example where I request the list view, which does not expect
arguments, to keep it even simpler.

urls.py

queryset = {'queryset': Adcall.objects.order_by('name')}

urlpatterns = patterns('django.views.generic.list_detail',
    url(r'^$','object_list', queryset, name="adcalls"),
    url(r'^(?P<object_id>\d+)/detail/$', 'object_detail', queryset,
name="detail"),
)


template:

EDIT TEMPLATE
{% load url from future %}
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>

<a href="{% url 'adcalls' %}">Back to adcall list</a>


Error:
NoReverseMatch at /testadcall/1/detail/

Reverse for 'adcalls' with arguments '()' and keyword arguments '{}' not found.





On Thu, Jan 24, 2013 at 2:53 AM, <mgc_django-us...@chamberlain.net.au>wrote:

> On 24/01/2013 10:39 AM, amy.cerr...@cbsinteractive.com wrote:
>
>> I've been trying to understand how to use generic views.  I've followed
>> some tutorials, and read through Django docs, but I can't get the url
>> function to work in my templates.
>>
>> I get the error
>> NoReverseMatch at /testadcall/
>> Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not
>> found.
>>
>> in my urls.py
>>
>> queryset = {'queryset': Adcall.objects.order_by('name'**)}
>>
>> urlpatterns = patterns('django.views.**generic.list_detail',
>>     url(r'^$','object_list', queryset, name="adcalls"),
>>     url(r'(?P<object_id>\d+)/**detail/$', 'object_detail', queryset,
>> name="detail"),
>> )
>>
>> in my template for the list view:
>>
>> {% load url from future %}
>> {% if object_list %}
>>     <ul>
>>     {% for adcall in object_list %}
>>         <li><a href="{% url 'detail' adcall.id %}/">{{ adcall.name}}</a></li>
>>     {% endfor %}
>>     </ul>
>> {% endif %}
>>
>> I've tried no quotes, single quotes, and double quotes around the url
>> name "detail", with no apparent effect.
>>
>> Am I wrong in thinking that this should work?
>>
>>
> The problem is a mismatch between your urls.py pattern and the parameters
> you give to the url templatetag - note in the error message that it
> mentions both arguments and keyword arguments (with your example having a
> single non-keyword argument). However, in your url pattern for the "detail"
> url, you use a named capture (object_id). In this case, you must use a
> keyword argument to match:
>
> {% url 'detail' object_id=adcall.id %}
>
> Regards,
> Michael.
>



-- 
Amy Cerrito
Engineering Manager, AdOps Technology
T 617.284.8697
55 Davis Sq, Somerville, MA 02143

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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