问题
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