I have been following a Django REST + vue.js tutorial and have encountered a problem in the end.
The task is to POST a new query if the id does not exist, edit otherwise.
The tutorial provides the following code for the purpose:
submitForm(){
if (this.movie.id === undefined) {
this.createMovie();
}
else {
this.editMovie();
}
I have confirmed that both createMovie
and editMovie
functions work properly, but the query does not enter the createMovie
section despite having no data that matches the provided id.
My solution was to introduce a new Boolean variable is_edit
, which would turn True
after clicking on the edit button, but the solution rendered the problem much more complex and I have no idea to proceed.
That said, is there any solution similar to the one that the tutorial provides?
Just in case, the link to the tutorial is: https://www.youtube.com/watch?v=7GWKv03Osek and for the entire project, https://github.com/Treeboy2762/app
Huge gratitude in advance!