How can i get csrftoken in view?

对着背影说爱祢 提交于 2021-02-06 15:19:02

问题


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.

Is there any way to do that?

Thanks!


回答1:


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?



来源:https://stackoverflow.com/questions/36347512/how-can-i-get-csrftoken-in-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!