[Fixed]-How to add csrf_token to manually created HTML form?

1👍

Found solution based on other SO post, and the method is to add a hidden field with csrf_token like:

res = format_html('''
<form method="POST">
  <input type="hidden" name="csrfmiddlewaretoken" value="{}" />
  {}
</form>''', csrf(html_request)['csrf_token'], ...)

Leave a comment