Is there a way to add meta-data to a handler?

2 views
Skip to first unread message

megaman821

unread,
Sep 15, 2009, 1:46:52 PM9/15/09
to django-piston
For example if you write a book handler that returns a list of books,
could you include the number of books returned?

jespern

unread,
Sep 15, 2009, 1:49:22 PM9/15/09
to django-piston
On Sep 15, 8:46 pm, megaman821 <megaman...@gmail.com> wrote:
> For example if you write a book handler that returns a list of books,
> could you include the number of books returned?

Sure. Try something like this:

def read(self, request):
books = Book.objects.all()

return { 'books': books, 'count': books.count() }


Jesper
Reply all
Reply to author
Forward
0 new messages