class DeviceResource(ModelResource):
class Meta :
queryset = Device.objects.all()
resource_name='device'
class UpdateResource(ModelResource):
device = fields.ForeignKey(DeviceResource, attribute='device',full=True, null=True)
class Meta :
queryset = Update.objects.all()
resource_name = 'update'
filtering = {'imei' : ALL }
更新模型有一个字段“IMEI”,它映射到“IMEI”在设备与ForeignKey的Tastypie |当Django的ForeignKey的使用“to_field”和相关资源不是主键
我想会有一些属性to_field与我可以写
device = fields.ForeignKey(DeviceResource, to_field='imei'attribute='device',full=True, null=True)
但有没有这样的事情在tastypie
这里是我的设备和更新型号
你检查RELATED_FIELD参数(在ressources)和[ related_name](http://django-tastypie.readthedocs.org/en/latest/fields.html#related-name)(在模型中)? – nnaelle
@nnaelle对不起,我没有完全让你。我做了这个'device = fields.ForeignKey(DeviceResource,attribute ='device',related_name ='imei',full = True,null = True)''和'device = fields.ForeignKey(DeviceResource,attribute ='device',related_field ='imei',full = True,null = True)',这不起作用 – ZenOut