0
我有兩個型號美味的餡餅搜索
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)
view.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
問題是我需要使用城市..我怎麼能做到這一點來篩選公司嗎?任何猜測
謝謝,你再次幫助我..謝謝 – 2013-02-11 17:13:00
我可以有你的emaid ..我對Django有很多疑問 – 2013-02-11 17:13:36
你可以從我的個人資料中得到我的郵件,但更好的方法是在這裏發佈你的問題,在這樣更多的人將從他們身上獲益,並且您將得到更可靠的答案。 – UnLiMiTeD 2013-02-11 21:54:29