Tuesday, April 9, 2013

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

Try this without quotes:
<a href="{% url contact_us %}">Contact Us</a>

On Tue, Apr 9, 2013 at 5:31 PM, Sithembewena Lloyd Dube
<zebra05@gmail.com> wrote:
> Hi everyone,
>
> I have a project based on the latest Django version (1.5.1.) where I created
> a contact_us application. The project has a urls.py file with some url
> patterns. The contact_us app implements its own urls.py file (decoupling).
> In the project's urls.py file (just above the admin site's url pattern), i
> have the following url pattern:
>
> url(r'^contact_us/', include('contact_us.urls', namespace="contact_us")),
>
> and in the contact_us app's urls.py file, I have the following url pattern:
>
> urlpatterns = patterns('',
> url(r'^$', views.contact_us, name='contact_us'),
> )
>
> In a template residing in the contact_us app's own templates folder, I use
> the url template tag as follows:
>
> <a href="{% url 'contact_us' %}">Contact Us</a>
>
> resulting in the following exception:
>
> NoReverseMatch at /contact_us/
>
> Reverse for 'contact_us' with arguments '()' and keyword arguments '{}' not
> found.
>
> Any ideas what I could be missing? I namespaced the contact_us urls include
> in the main urls'py file and there is a simple contact_us view in the
> contact_us app which renders an existing template.
>
> Thanks.
> --
> Regards,
> Sithu Lloyd Dube
>
> --
> 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.
>
>



--
Best regards,
Andrey Kostakov
Email/Gtalk: bps@dzen.ws

--
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