I wanted to introduce custom editable field in Django Admin list view. I wanted to do something very similar to this question.
The problem that I am facing is that Django requires that all fields from list_editable
must be fields in a 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 name
field on model it doesn't work, validation fails.
Edit: The specific validation error I am getting:
django.core.exceptions.ImproperlyConfigured: 'SomeModelAdmin.list_editable' refers to a field, 'name', not defined on SomeModel.
You can see this place in sources: Django sources.