Reputation: 1276
I want bind data sent by ajax to django form. Inside view I'm trying to bind data something like this:
form = RhymeForm(request.body)
# request.body: {"content":"<p>a</p>","title":""}
I cant get any validation errors, so how to bind data send by ajax to form?
Upvotes: 0
Views: 76
Reputation: 5841
request.body
is just text payload. To use it as the data for the form, you should unpack it first:
form = RhymeForm(json.loads(request.body))
Upvotes: 1