This is the first time i am using REST for any web applications.
For normal get
an post
and i simply call the API done in Django Rest Framework.
But i am not able to think how can i deal with situations where something more needs to be done.
Suppose I have
- List of users in database and their product they have bought.
Now i have web form where if someone adds the user and then submit the button , then
- I have to get the list of items bought by that user in 5 hour window
- Update the row in database which says buy_succeessful to false
- Then again get the list of orders from the items he has bought and then update the rows with order_successful to false
Now current in my submit actions i am doing like
- call to api to add the user in override manual enrty table. This is simple post to that table
Then after getting the sucessful tehn i again call api to list of items this user has bought using Query parameters . Then i have the list
Then again i loop through the list and post to api for updating that record in datbase
and so on
I am feeling this is not right.
I have found that quite often there are some more things to do tahn just saving individual objects in database.
whats the best way to do that. DO i need to have view api for every function