我想将模型字段渲染为复选框,以便我将选项预定义为元组列表,我该怎么做?
class Car(models.Model):
groups = models.CharField(max_length=100,
blank=False)
class CarAdmin(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(CarForm, self).__init__(*args, **kwargs)
self.fields['groups'].widget = forms.CheckboxSelectMultiple(choices=CARS_ALLOWED)