In Django admin Panel. I have a model which has fields like userID, name, status. I want to call an API (e.g:- www.xyx.com?user=userID&status='approved') when status="approved" is selected and click on save button.
Hitting an API from Django admin Panel
2.5k Views Asked by Rohit Kumar At
1
You can override the
save_model()
method inModelAdmin
. From there, you can make the API request before delegating the save operation itself to the parent class.For example, assuming your model class is called
MyModel
, and that you are using the Requests library to call the API: