Django模型表单集-过滤外键字段

时间:2018-09-11 13:48:40

标签: django django-forms

我有一个ModelFormSet,它具有一个外键字段。我想对此进行过滤,因此它不会显示所有外键属性:

型号:

class ClinicallyReportedVariant(models.Model):

    vasr_id = models.ForeignKey(VariantAnnotationSampleRun,
                on_delete=models.CASCADE, db_column='vasr_id',
                related_name='vasr_id', null=True, blank=True)
    reported = models.BooleanField(default=False)
    date_reported = models.DateTimeField(auto_now=False,
                                null=True, blank=True)

观看次数:

    CRVFormSet = modelformset_factory(
                    ClinicallyReportedVariant,
                    exclude=('clinically_reported_sample_id',),
                )

    formset = CRVFormSet()

我想基于VariantAnnotationSampleRun模型过滤CRVFormSet。我怎样才能做到这一点? ClinicallyReportedVariant表为空-因此,我不想基于表单集查询集进行过滤

0 个答案:

没有答案