You need to override the form that ModelAdmin will use:
class MyForm(forms.ModelForm): stuff = forms.CharField('Stuff', max_length=255, choices=MY_CHOICES, default=None) class Meta: model = MyModel fields = ('stuff', 'other_field', 'another_field') class MyModelAdmin(admin.ModelAdmin): fields = ('stuff',) list_display = ('stuff',) form = MyForm()
If you need your choice to be dynamic, perhaps you could do something similar to:
class MyForm(forms.ModelForm): stuff = forms.CharField('Stuff', max_length=255, choices=MY_CHOICES, default=None) def __init__(self, stuff_choices=(), *args, **kwargs):
and in ModelAdmin __init__ specify what will be MY_CHOICES , and instead assign an instance of the form:
Good luck! :)
Gerard
source share