开发者

Django - models.CharField- choices - Option Buttons instead of Select box

开发者 https://www.devze.com 2023-01-26 15:08 出处:网络
Formodels.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 (

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消