django.db.models.fields.related_descriptors.RelatedObjectDoesNotExist: FixOr
der has no company_id.
FixOrder表company_id为None的时候取字段报的错,company_id是个外键
解决办法:在model中添加 blank=True, null=True,即:
company_id = models.ForeignKey('baselib.Company',db_column='company_id',blank=True, null=True)
本文介绍了一个关于Django中ForeignKey字段引发的RelatedObjectDoesNotExist异常,并提供了解决方案,通过在model定义中设置blank=True和null=True来允许字段为空。
3722

被折叠的 条评论
为什么被折叠?



