Django - models.CharField- choices - Option Buttons instead of Select box
For models.CharField()
, we use to give a choices
attribute. Normally these choices will be displayed in select box. Is it possible to display the option buttons ins开发者_如何学JAVAtead of select box (in admin interface)? Any suggestions?
status = models.CharField(max_length = 25, choices = (('IN PROGRESS', 'IN PROGRESS'),('COMPLETED','COMPLETED')))
The following ModelAdmin subclass (in your admin.py) does what you're after:
class PersonAdmin(admin.ModelAdmin):
radio_fields = {"group": admin.VERTICAL}
HORIZONTAL is also possible.
From the Django docs.
精彩评论