toastdriven/restless

Unable to add pagination meta data to response dict

Grokzen opened this issue · 2 comments

I want to add pagination meta data to a response when i do a GET request to my API.

I can handle the pagination djangos built -in Paginator class but the problem is that my list() expects a colection/itterator of items to serialize. So I cannot return the collection from my pagiinator + the meta data from that paginator object.

@Grokzen First, I love the avatar. Such StarCrafts.

You should be able to override Resource.wrap_list_response(...) (within your subclass) to inject the pagination data. That's only called on list endpoints & controls the overall structure returned. See https://github.com/toastdriven/restless/blob/master/restless/resources.py#L455-L476 for the implementation.

That tip was useful! Perhaps it should be in the documentation ;)