如果您正在寻找一种使用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?!'... }