私は API を取得して、tastypie との逆の関係データを取得しようとしています。
DocumentContainer と DocumentEvent の 2 つのモデルがあり、次のように関連しています。
DocumentContainer には多くの DocumentEvent があります
これが私のコードです:
class DocumentContainerResource(ModelResource):
pod_events = fields.ToManyField('portal.api.resources.DocumentEventResource', 'pod_events')
class Meta:
queryset = DocumentContainer.objects.all()
resource_name = 'pod'
authorization = Authorization()
allowed_methods = ['get']
def dehydrate_doc(self, bundle):
return bundle.data['doc'] or ''
class DocumentEventResource(ModelResource):
pod = fields.ForeignKey(DocumentContainerResource, 'pod')
class Meta:
queryset = DocumentEvent.objects.all()
resource_name = 'pod_event'
allowed_methods = ['get']
API URL にアクセスすると、次のエラーが表示されます。
DocumentContainer' object has no attribute 'pod_events
誰でも助けることができますか?
ありがとう。