[Answered ]-Django admin – prevent changing a field after it has become true

1👍

You can make use of ModelAdmin.get_readonly_fields() method.

Give this a try:

class OrderAdmin(admin.ModelAdmin):
    ...

    def get_readonly_fields(self, request, obj=None):
        readonly_fields = super(OrderAdmin, self).get_readonly_fields(request, obj)

        if obj.is_called:
            readonly_fields.append("is_called")
            return readonly_fields

        return readonly_fields

Leave a comment