Python 显示现有实例的django modelform

Python 显示现有实例的django modelform,python,django,django-forms,Python,Django,Django Forms,我有以下型号: ynChoice = ((None, 'Acknowledgement not required'), (True, 'Acknowledgement and consent required'), (False, 'Acknowledgement required but consent not required')) class AbstractForm(models.Model): """base class for

我有以下型号:

ynChoice = ((None, 'Acknowledgement not required'),
            (True, 'Acknowledgement and consent required'),
            (False, 'Acknowledgement required but consent not required'))

class AbstractForm(models.Model):
    """base class for the below 2 classes"""
    #require users to say yes and no other than acknowledging #null = not required
    yes_no_required = models.NullBooleanField(choices=ynChoice, blank=False)
我将其映射到我的模型表单:

class LiveConsentForm(forms.ModelForm):
    ynChoice = (
                ('', '---------------'),
                (None, 'Acknowledgement not required'),
                (True, 'Acknowledgement and consent required'),
                (False, 'Acknowledgement required but consent not required'),
                )
    yes_no_required = forms.TypedChoiceField(choices=ynChoice,empty_value='')
    class Meta:
        model = ConsentFormTemplate
这里,
approvementformtemplate
AbstractForm
的一个子类。我在表单中写入了
yes\u no\u required
,因为nullbooleanfield的formfield的空值将返回一个
None
,这是我不想要的

现在,当我想实例化我的表单以显示现有记录时,
liveapproverform(instance=templateInstance)
,我遇到了一个问题

My
templateInstance.yes\u no\u required
的值为None,但在呈现html时,
----
被选中。(当
需要的
为假
时,我不会遇到这种问题)


这里需要一些帮助。

好的,我已经查看了forms.fields和

结果表明,在呈现为html时,没有一个被视为“”,此处不考虑空的_值。我不知道为什么@Ignacio Vazquez Abrams dude拿走了他的答案,所以如果你能把它放回去,我会接受的