Using {% url ??? %} in django templates

后端 未结 6 2328
囚心锁ツ
囚心锁ツ 2020-12-07 13:02

I have looked a lot on google for answers of how to use the \'url\' tag in templates only to find many responses saying \'You just insert it into your template and point it

6条回答
  •  温柔的废话
    2020-12-07 13:48

    Make sure (django 1.5 and beyond) that you put the url name in quotes, and if your url takes parameters they should be outside of the quotes (I spent hours figuring out this mistake!).

    {% url 'namespace:view_name' arg1=value1 arg2=value2 as the_url %}
     link_name 
    

提交回复
热议问题