http://192.168.1.21:8888/mobapp/api/v1/events_by_cat/?format=json&limit=100&zip=T3C1S1
class EventsListResource(ModelResource):
category = fields.ToManyField(EventCategoryResource, 'category',related_name='events_by_cat')
venue = fields.ForeignKey(VenueResource, 'venue')
class Meta:
queryset = Event.objects.filter(status='P').order_by('end_date','-tdate','-start_date')
resource_name = 'events_by_cat'
fields = ['title','resource_uri','venue','listing_type','start_date','event_description']
filtering = {
'title':ALL_WITH_RELATIONS,
'category': ALL,
'listing_type':['exact'],
'start_date':ALL,
'venue':ALL,
'zip':ALL
}
def dehydrate(self,bundle):
bundle.data['resource_uri'] = bundle.data['resource_uri'].replace("events_by_cat", "eventlist");
bundle.data['event_description'] = filter_content(bundle.data['event_description'])
image = bundle.obj.get_cover_image()
bundle.data['image'] = get_thumbnail_image(image)
bundle.data['venuename'] = bundle.obj.venue
bundle.data['zip'] = bundle.obj.venue.zip
if bundle.obj.start_time:
bundle.data['date_time'] = bundle.obj.start_date.strftime("%a, %b %d,")+' '+bundle.obj.start_time.strftime("%I:%M%p")
else:
bundle.data['date_time'] = bundle.obj.start_date.strftime("%a, %b %d")
return bundle