简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM