Reputation: 414
I would like to run a backend code after pressing the 'Save' button in the change_form (admin) screen, which will be followed by a confirmation dialog box which will ask something like 'nothing found, create new entity anyway?' By pressing 'ok' in the dialog box the application will continue with the normal 'save' functionality. Pressing the 'cancel' button will throw us back to the change_form screen.
The workflow i'm trying to achieve is: Press 'save' > run a python validation code > if code returns 'false' continue with the original 'save' functionality, else popup a dialog box > [dialog box] Ok > save the entity, cancel > stay on the change_form page.
Thanks for the help
Upvotes: 1
Views: 2898
Reputation: 620
I was looking for something similar, to show a confirmation popup before updating some values and I found a library django-admin-confirm posting here for future explorers.
Upvotes: 0
Reputation: 14180
Add a listener on the submit button with jQuery. Then fire off an Ajax request to the server to see if something has been found or not. Then display the dialog accordingly.
Upvotes: 1