Updating my template code to use namespace:url_name did it!

list url:

<a href="{% url 'testadcall:adcalls' %}">List of all ad calls</a>

detail url:

<a href="{% url 'testadcall:detail' object_id=adcall.id %}">

Thanks again for everyone's feedback!  


On Thursday, January 24, 2013 10:07:14 AM UTC-5, Tom Christie wrote:
>
> Hi Amy,
>
> I'd suggest you check the following...
>
> * Your 
> ROOT_URLCONF<https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf>setting
>  is correct.
> * If the `urls.py` module you're referring to here is a project URL conf 
> and not the root URL conf, make sure that it is being included by the root 
> URL conf.  (This seems like the most likely cause)
> * If it is being included by the root URL conf, check if it's being 
> included with a `namespace` argument, and if so make sure to prefix the 
> reverse with the appropiate namespace, eg if it's namespaced as 'myapp', 
> then use 'myapp:addcalls'.
>
> You've already made things really simple, the URL conf as you've declared 
> it looks correct, so this...
>
>    Reverse for 'adcalls' with arguments '()' and keyword arguments '{}' 
> not found.
>
> Suggests that 'adcalls' simply isn't included part of the URL conf of the 
> application.
>
> Cheers,
>
>   Tom
>
> On Thursday, 24 January 2013 14:01:30 UTC, Amy Cerrito wrote:
>>
>> 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_djan...@chamberlain.net.au> wrote:
>>
>>> On 24/01/2013 10:39 AM, amy.c...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/3kSpsT_r7jAJ.
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