Tuesday, April 9, 2013

Re: {% url %} template tag not resolving app url in template

On Tue, Apr 9, 2013 at 3:43 PM, Sithembewena Lloyd Dube
<zebra05@gmail.com> wrote:
> Thanks, Tom.
>
> I am not sure how you mean? In the contact_us app, I am not explicitly
> calling reverse. I only have the following:
>
> from django.shortcuts import render, reverse
>
> def contact_us(request):
> return render(request, 'contact_us/contact_us.html')
>

In your template you have

{% url 'contact_us' %}

But in your urls.py you have given all urls in that app a namespace.
Therefore, you must use the namespace if you wish to reverse it - the
url tag simply calls reverse(). Hence:

{% url 'contact_us:contact_us %}

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate