Home:ALL Converter>Custom button not performing action in Django admin

Custom button not performing action in Django admin

Ask Time:2021-05-08T18:24:37         Author:Lutaaya Huzaifah Idris

Json Formatter

Am trying to add another custom button, and at the same time I want it to trigger certain processes in Django-admin with templates, below is how I have implemented the template :

{% extends 'admin/custominlines/change_form.html' %}
{% load i18n %}
 {% block submit_buttons_bottom %}
     {{ block.super }}
       {% if request.GET.edit %}
        <div class="submit-row">
            <input type="submit"  value="Custom button" name="_transition-states">
        </div>
     {% endif %}
{% endblock %}

The button does appear however, when I click it , it doesn't show the print I have inserted in the response_change() function in the admin.py, what am I missing here :

 def response_change(self, request, obj):
        if '_transition-states' in request.POST:
            print("am working")
        return super().response_change(request, obj)

When I click the button it just routes back to the previous page.

Author:Lutaaya Huzaifah Idris,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/67446494/custom-button-not-performing-action-in-django-admin
yy