我正在尝试创建此报表模型的实例:
class Report(models.Model):
"""
A model for storing credit reports pulled from Equifax.
"""
user = models.ForeignKey(to=CustomUserModel, on_delete=models.CASCADE,
help_text='User report belongs to.')
timestamp = models.DateTimeField(default=timezone.now)
report = JSONField()
然而,每当我试图得到这个错误:
Exception Type: TypeError at /internal/report
Exception Value: 'report' is an invalid keyword argument for this function
如果我使用
Report().save()
方法,或
Report.object.create()
方法如下:
report_obj = Report.objects.create(
user=user,
report=report
)
有人知道发生了什么事吗?很明显,这个类有一个“report”属性,为什么会出错?
谢谢!