Philip007
Philip007

Reputation: 3230

Django template url tag

After reading many sources, I am confused about what should be inside {% url "xxx" %} (quotes for Django 1.5). Is it the path to a view function, or is it the name of a named url pattern?

Both seem to be correct, mentioned in different places in official Django documentation.

Upvotes: 0

Views: 1004

Answers (1)

Rohan
Rohan

Reputation: 53316

As written in first link, both view function or url name pattern can be used in the {%url%} tag. And the whatever it is put that in quotes.

Warning :

Don’t forget to put quotes around the function path or pattern name!

Changed in Django 1.5: The first parameter used not to be quoted, which was inconsistent with other template tags. Since Django 1.5, it is evaluated according to the usual rules: it can be a quoted string or a variable that will be looked up in the context.

Upvotes: 2

Related Questions