Django conditional admin list_editable
As you say, there is no get_list_editable
method.
Try overriding the get_changelist_formset
method. I think you'll need to duplicate the entire method, and change the list of fields passed to modelformset_factory
.
As said, there is not get_list_editable
method in the ModelAdmin
class, but it is possible to implement it easily (tested on django==2.1
):
class MyAdminClass(admin.ModelAdmin):
def get_list_editable(self, request):
"""
get_list_editable method implementation,
django ModelAdmin doesn't provide it.
"""
dynamically_editable_fields = ('name', 'published', )
return dynamically_editable_fields
def get_changelist_instance(self, request):
"""
override admin method and list_editable property value
with values returned by our custom method implementation.
"""
self.list_editable = self.get_list_editable(request)
return super(MyAdminClass, self).get_changelist_instance(request)