How can i get csrftoken in view?

后端 未结 1 1858
臣服心动
臣服心动 2021-02-13 04:44

Is there any way to get csrftoken in View straightly?

I want to get the current csrftoken in view but will change sometimes so get it from Cookies is not a good idea.

相关标签:
1条回答
  • 2021-02-13 05:11

    I believe you're looking for this:

    django.middleware.csrf.get_token(request)
    

    or

    {% csrf_token %}
    

    Reference: How can I embed django csrf token straight into HTML?

    0 讨论(0)
提交回复
热议问题