I'm trying to use the get_list tastypie function but I can't make it work. I've looked for documentation about that but I can't find it.
Whatever, I've a list of item ids and an ItemResource. I'm trying to return a list of serialized objects. So I just want to do something like that :
item_resource = ItemResource()
item_ids = my_item_id_list
return item_resource.get_list(request, id=item_ids)
But of course it's not working. What would be the correct syntax to do that ?
Thx !
Unless your ItemResource
accepts filters
(more here), you have to copy-paste all the stuff from here, lines #1306 - #1313.
The point is that get_list
results get filtered only by obj_get_list
(initial filters), and apply_filters
(request-specific filters) so you have to skip directly to the serialization part (you can include the pagination part, if needed).
This is one of the cases where django-restframework
appears to be better than django-tastypie
- it refactores serialization out into a separate class, avoiding the code duplication.