Hi, I’m doing a project that the answer of this question is important for me. I will thank to give me the answer.
I have a form in front end that is created by vue.js and I want to post the submitted data to django rest framework by axios to create some objects by those records in the database but I don’t know how to post the data completely. What do I have to do in both vue js and django to have access to the submitted data?
Thanks.
You have two options:
- Use Django forms and then use axios to submit a POST as if it were a form submission.
- Create an API (probably with DRF) and then have axios post the relevant JSON to the DRF endpoint.
The other thing you have to handle is CSRF validation. There are a couple different options discussed here for that: javascript - Proper Django CSRF validation using fetch post request - Stack Overflow
Hope that helps!
Cory
Thank you very much.