3

I'm starting to learn about Django Framework. I have this urls in my urls.py

from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
    # Examples:
    url(r'^hello/$','article.views.hello'),
)

My questions are:
Can I give this routes a name, like i would in Laravel?
How can i reference those named routes from template?

Thanks!

1 Answer 1

7

Yes, you can:

url(r'^hello/$','article.views.hello', name="hello"),

You would reference it in a template as:

{% url 'hello' %}

For more information, including how to give arguments to a named URL, see here.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.