Tastypie get latest record -


instead of returning multiple objects when id isn't set. i'd return one, latest.

# return latest entry /api/entry/ {'id': 2, 'foo': 'bar', ...}  # return specified entry /api/entry/1/ {'id': 1, 'foo': 'bar', ...} 

i've tried overriding both obj_get_list , get_object_list, neither worked me.

do need create view this?

using aniav's solution, , adding necessary modifications:

resource     class meta:          max_limit=1     get_object_list(self,request):         return super(self, resource).get_object_list(request).filter(user=request.user).order_by('-date') 

where of course date replaced field want latest of.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -