鉴于以下 API 定义,我需要能够按产品别名过滤事件。
鉴于 Event 属于 Job 并且 Job 属于 Product 我不确定如何指定。
api.py:
class ProductResource(ModelResource):
class Meta:
queryset = Product.objects.all()
resource_name = 'product'
allowed_methods = ['get']
excludes = ['created_at','updated_at']
filtering = {
'alias': ALL
}
class EnvironmentResource(ModelResource):
class Meta:
queryset = Environment.objects.all()
resource_name = 'environment'
allowed_methods = ['get']
excludes = ['created_at','updated_at']
class JobResource(ModelResource):
product = fields.ForeignKey(ProductResource, 'product')
class Meta:
queryset = Job.objects.all()
resource_name = 'job'
allowed_methods = ['get']
excludes = ['created_at','updated_at']
class EventResource(ModelResource):
environment = fields.ForeignKey(EnvironmentResource, 'environment',full=True)
job = fields.ForeignKey(JobResource, 'job',full=True)
class Meta:
queryset = Event.objects.all()
resource_name = 'event'
allowed_methods = ['get']
excludes = ['created_at','updated_at']
filtering = {
HOW DO I FILTER BY PRODUCT ALIAS????
}