0

I'm working with Restless and as stated in the documentation, returning Model.objects.all() produces something like this:

{
    "objects": [
        {
            "id": 1,
            "title": "First Post!",
            "author": "daniel",
            "body": "This is the very first post on my shiny-new blog platform...",
            "posted_on": "2014-01-12T15:23:46",
        },
        {
            # More here...
        }
    ]
}

This works fine. However, I don't want the "objects" wrapper to be here. My front-end code expects an array. Is there any way of telling Restless not to wrap the array?

gkpo
  • 2,623
  • 2
  • 28
  • 47
  • I am not experienced with restless but an [alternative serializer](http://restless.readthedocs.org/en/latest/extending.html#alternative-serialization) might be the way to go. – Selcuk Mar 11 '15 at 22:39
  • I found a way around it: change the behaviour of the front-end instead of the back-end: http://stackoverflow.com/questions/22012655/restangular-getlist-with-object-containing-embedded-array – gkpo Mar 12 '15 at 08:58

1 Answers1

0

You can do this by overriding method Resource.wrap_list_response(). Default implementation just wraps data in a dictionary (within the objects key), you can modify this to return data unchanged.

Palasaty
  • 5,181
  • 1
  • 26
  • 22