class Event(Basetable):
title = models.CharField(max_length=150)
event_description = models.TextField()
image = ThumbnailerImageField(upload_to=get_eventlogo_path, resize_source=dict(size=(700, 0), crop='smart'),)
category = models.ManyToManyField("EventCategory")
venue = models.ForeignKey(Venue,null=True)
class Venue(models.Model):
venue = models.CharField(max_length=100)
address1 = models.CharField(max_length=200)
address2 = models.CharField(max_length=200,blank=True)
slug = models.CharField(max_length=150,blank=True,null=True)
country = models.ForeignKey(Countries,null=True,blank=True,on_delete=models.SET_NULL)
state = models.ForeignKey(States,null=True,on_delete=models.SET_NULL)
city = models.ForeignKey(City,null=True,on_delete=models.SET_NULL)
class EventResource(ModelResource):
venue = fields.ForeignKey(VenueResource, 'venue')
class Meta:
queryset = Event.objects.filter(status='P').order_by('-id').distinct()
resource_name = 'eventlist'
filtering = {
"slug": ('exact', 'startswith',),
"title": ALL,
}
我的问题是我需要使用位于场地的城市来获取活动结果
ex www.example.com/api/v1/eventlist/?format=json&city="chicago“但它不会帮助我
答案 0 :(得分:3)
您必须允许按地点过滤:
filtering = { 'venue': ALL_WITH_RELATIONS
}
此链接可以使用。 www.example.com/api/v1/eventlist/?format=json&venue_city_name="chicago“