S
S
Shandy2021-07-23 15:19:07
Django
Shandy, 2021-07-23 15:19:07

how to get json from html form?

There is a form on the page

<form action="/post" method="post">
<input name="email">
<input name="name">
<button type="submit">отправить</button>
</form>

How to get the json that the form gives? I found this code somewhere, but it doesn't work.
data = json.loads(request.body.decode())
Mistake
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
javedimka, 2021-07-23
@javedimka

The form does not provide json. The form gives a multipart/form-date.
Forms in janga work through forms.
https://docs.djangoproject.com/en/3.2/topics/forms/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question