This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 24th, 2013  |  syntax: None  |  size: 1.45 KB  |  views: 74  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. http://192.168.1.21:8888/mobapp/api/v1/events_by_cat/?format=json&limit=100&zip=T3C1S1
  2.        
  3. class EventsListResource(ModelResource):
  4.     category   = fields.ToManyField(EventCategoryResource, 'category',related_name='events_by_cat')
  5.     venue      = fields.ForeignKey(VenueResource, 'venue')
  6.  
  7.     class Meta:
  8.         queryset = Event.objects.filter(status='P').order_by('end_date','-tdate','-start_date')
  9.         resource_name = 'events_by_cat'
  10.         fields = ['title','resource_uri','venue','listing_type','start_date','event_description']
  11.         filtering = {
  12.             'title':ALL_WITH_RELATIONS,
  13.             'category': ALL,
  14.             'listing_type':['exact'],
  15.             'start_date':ALL,
  16.             'venue':ALL,
  17.             'zip':ALL
  18.  
  19.         }
  20.  
  21.     def dehydrate(self,bundle):
  22.         bundle.data['resource_uri'] = bundle.data['resource_uri'].replace("events_by_cat", "eventlist");
  23.         bundle.data['event_description'] = filter_content(bundle.data['event_description'])
  24.         image = bundle.obj.get_cover_image()
  25.         bundle.data['image'] = get_thumbnail_image(image)
  26.  
  27.         bundle.data['venuename'] = bundle.obj.venue
  28.         bundle.data['zip'] = bundle.obj.venue.zip
  29.  
  30.         if bundle.obj.start_time:
  31.             bundle.data['date_time'] = bundle.obj.start_date.strftime("%a, %b %d,")+' '+bundle.obj.start_time.strftime("%I:%M%p")
  32.         else:
  33.             bundle.data['date_time'] = bundle.obj.start_date.strftime("%a, %b %d")
  34.  
  35.         return bundle
clone this paste RAW Paste Data