我有以下内容:
模型.PY
LIST = (('Manager', 'Manager'),('Non-Manager', 'Non-Manager'),)
class Employee(models.Model):
fname = models.CharField(max_length=15, blank=False, null=False)
manager = models.CharField(max_length=15, choices=LIST, blank=True, null=True)
comment = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.fname
class EmployeeForm(forms.ModelForm):
fname = forms.CharField(required=True, label='First Name')
manager = forms.CharField(required=False, widget=Select(choices=LIST), label='Their Position?')
comment = forms.CharField(required=False, widget=forms.Textarea(attrs={'cols': 50, 'rows': 10}), label='Comments')
class Meta:
model = Employee
如果我从 EmployeeForm 中删除经理,我会在表单下拉菜单中获得一个“------”作为选项,但如果我将经理保留在 EmployeeForm 中(并且我需要覆盖字段标签) ,它会删除“------”。如何让 EmployeeForm 保留“------”选项?