复选框而不是DJANGO ADMIN上的单选按钮?

时间:2019-03-19 20:50:39

标签: django django-models django-admin django-modeladmin

如果您正在寻找一种使用MODELS在Django中放置单选按钮的方法,则只需执行以下操作(例如):

在models.py

class MonitoringPointsClass( models.Model ):

    monitoring_has_power = models.BooleanField(
       null = True, max_length = 1,
       default = None,
       choices = YES_NO,
       name = 'monitoring_has_power',
       blank = True,
       verbose_name = _( 'Electrified' ), )
    ...

在admin.py

class MonitoringPoints_InLine_MODELadmin( admin.ModelAdmin ):
    model = MonitoringPointsClass

    radio_fields = {
            'monitoring_has_power'   : admin.HORIZONTAL,
            ...
    }

    checkboxes_fields = {
            'it's do not exists I guess, why?!'... }

但是我还是找不到使用复选框而不是单选按钮来做到这一点

0 个答案:

没有答案