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

后端 未结 6 2339
囚心锁ツ
囚心锁ツ 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:41

    Instead of importing the logout_view function, you should provide a string in your urls.py file:

    So not (r'^login/', login_view),

    but (r'^login/', 'login.views.login_view'),

    That is the standard way of doing things. Then you can access the URL in your templates using:

    {% url login.views.login_view %}
    

提交回复
热议问题