实际上我们有 2 个模型
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" 但它不会来帮助我