[Django]-Django admin : How to call an action on a click of custom button?

3👍

All u need is here:

https://medium.com/@hakibenita/how-to-add-custom-action-buttons-to-django-admin-8d266f5b0d41

Follow the easy steps and your ready to go.
Many others all around the web.

1👍

0👍

You can add a URL like this to call a function

     def get_urls(self):
        urls = super().get_urls()
        custom_urls = [
            path(
                'penalty/<int:id>',
                self.admin_site.admin_view(self.penalty),
                name='penalty'
            )
        ]
        return custom_urls + urls

from a button click in Django admin

Leave a comment