1<form action="{% url "submit-form-url-name" %}" method="post" accept-charset="utf-8">
2 {% csrf_token %}
3 {{ form.field1 }}
4 {{ form.field2 }}
5 ...
6</form>
1{% csrf_token %}
2<script>
3const csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value;
4</script>
5