我有两个型号
class Business(Basetable):
name = models.CharField(max_length=120)
slug = models.SlugField(max_length=150)
logo=models.OneToOneField("BusinessLogo",null=True,on_delete=models.SET_NULL)
class Address(models.Model):
business = models.ForeignKey("Business", related_name='biz_address')
address1 = models.CharField(max_length=100,null=True)
address2 = models.CharField(max_length=100,null=True)
state = models.ForeignKey(States,null=True,on_delete=models.SET_NULL)
city = models.ForeignKey(City,null=True,on_delete=models.SET_NULL)
视图.py
class BusinessResource(ModelResource):
class Meta:
queryset = Business.objects.filter(status='P').order_by('-id')
resource_name = 'business'
filtering = {
'is_black_business': ALL,
'city': ALL_WITH_RELATIONS,
}
def dehydrate(self,bundle):
if buss_address.city:bundle.data['city'] = buss_address.city.name
else:bundle.data['city'] = ''
// i am getting city here
问题是我需要使用城市过滤业务..我该怎么做?任何猜测