[Django]-How can I create a button for a django admin action?

4πŸ‘

βœ…

I don’t think admin actions are the best fit in this case.

Actions are

simple functions that get called with a list of objects selected on the change list page

With the buttons you describe however, you want to operate on a single row/instance.
Therefore I would simply create a custom url endpoint for your ModelAdmin which is called when you press the button and which handles the desired action.

This article has quite a comprehensive overview how this can be done in detail.

πŸ‘€arie

Leave a comment