我无法弄清楚为什么我的UserResource总是为每个对象显示null,即使在Observation_by_id正确地位于Observation模型的数据库中。
相关代码:
class Observation(ProjModel):
verified_by = models.ForeignKey(User, null=True)
class Meta():
app_label = 'observation'
class ObservationResource(ProjResource):
verified_by = fields.ForeignKey(UserResource, 'user', full=True, null=True)
class Meta:
queryset = Observation.objects.all()
authentication = SessionAuthentication()
authorization = DjangoAuthorization()
resource_name = 'observation'
class UserResource(ProjResource):
class Meta:
queryset = User.objects.all()
authentication = SessionAuthentication()
authorization = DjangoAuthorization()
resource_name = 'user'
"objects": [{"verified_by": null}]
答案 0 :(得分:1)
您需要确保所有引用的Resources
都在您的网址结构中,以便它们出现。