Custom changelist and list_editable in Django Admin
I wanted to introduce a custom editable field in the Django Admin list view. I wanted to do something very similar to this question .
The problem I am facing is that Django requires all fields from to list_editable
be fields in the model.
class SomeModel(Model):
...
class SomeModelChangeListForm(forms.ModelForm):
class Meta:
model = SomeModel
name = forms.CharField()
class SomeModelAdmin(admin.ModelAdmin):
def get_changelist_form(self, request, **kwargs):
return SomeModelForm
list_display = ['name']
list_editable = ['name']
So, if there is no field on the model name
, it doesn't work, no validation is performed.
Edit : The specific validation error I'm getting:
django.core.exceptions.ImproperlyConfigured: "SomeModelAdmin.list_editable" refers to the "name" field, not defined on SomeModel.
You can see this place in the sources: Django Sources .
+3
source to share