When using list_editable in ModelAdmin
, is there any way to change the widget used for the editable fields? I can\'t find anything in the documentation. Seems like
Override get_changelist_form
method of your ModelAdmin
class, like so:
def get_changelist_form(self, request, **kwargs):
kwargs.setdefault('form', MyAdminForm)
return super(MyModelAdmin, self).get_changelist_form(request, **kwargs)
And separately define the modified MyAdminForm
:
class MyAdminForm(forms.ModelForm):
class Meta:
model = MyModel
my_field = forms.DateField(widget=widgets.AdminDateWidget())
This is just an example which will make my_field
represented by a widget for only the date (without time). That looks much better in the list view.