hello alex.l
Thank you for your support.
The following permissions will prevent the system from functioning as a cloud system:
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.AllowAny',),
In Django Template THML, configure it as follows:
<form method="POST" enctype='multipart/form-data' name="form">
{%csrf_token%}
{{ form.non_field_errors }}
<div class="d-flex form-row">
<div class="p-1 w-25">
{{ form.estimate_no.label_tag }}
{{ form.estimate_no }}
<span class="helptext">{{ form.estimate_no.help_text }}</span>
{{ form.estimate_no.errors }}
</div>
<div class="p-1 w-75">
{{ form.estimate_name.label_tag }}
{{ form.estimate_name }}
<span class="helptext">{{ form.estimate_name.help_text }}</span>
{{ form.estimate_name.errors }} </div>
</div>
<div class="d-flex flex-row">
<button class="btn btn-primary btn-sm mx-2" type="submit">create</button>
<button class="btn btn-secondary btn-sm mx-2" type="reset">reset</button>
<a class="btn btn-warning btn-sm mx-2" href="{% url 'estimate:estimate_list' %}">estimate list</a>
</div>
</form>
Handling AJAX is described in the Django manual.
https://docs.djangoproject.com/ja/6.0/howto/csrf/
Setting the token on the AJAX request¶
Finally, you’ll need to set the header on your AJAX request. Using the fetch() API:
const request = new Request(
/* URL */,
{
method: 'POST',
headers: {'X-CSRFToken': csrftoken},
mode: 'same-origin' // Do not send CSRF token to another domain.
}
);
fetch(request).then(function(response) {
// ...
});
Is your company's system incomplete in terms of Django REST Framework support?
Hiroaki Ono from Tokyo