'How to disable specific change_actions button in Django admin?
I have a set of change_actions buttons on my Django Admin page:
A part of code for this particular InvoiceAdmin page:
from django_object_actions import DjangoObjectActions
class InvoiceAdmin(NGModelAdmin):
def invoice_lines_link(self, request, obj):
""" Set a button to the page of the Invoice's Invoice lines in the details view
"""
return HttpResponseRedirect("{url}?invoice__pk={pk}".format(
url=reverse("admin:backend_invoiceline_changelist"), pk=obj.pk
))
invoice_lines_link.label = "Invoice Lines"
def customer(self, request, obj):
""" Set a button to the page of the InvoiceLine's Customer in the details view
"""
return HttpResponseRedirect(reverse(
"admin:backend_customer_change",
args=[obj.customer.id]
))
change_actions = ('customer', 'invoice_lines_link', 'test_link', 'pdf',)
I would like to have a button disabled, when other action in called.
How can i refer to that button and disable it?
It is not in a form and not marked as a action, so both get_form() and admin.site.disable_action wont work.
(I want to disable one of the grey buttons, that you can notice on the picture - it is not related to the form)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

