How to make a group-by/count with django rest framework?

4,779 views
Skip to first unread message

Robert K

unread,
Aug 19, 2016, 7:03:12 PM8/19/16
to Django REST framework
Hi,
has anybody an idea how to realize a group-by/count with django rest framework? Im searched around on the internet but cant find a working solution...

I have a model with this fields: id, user, session

What i want is a count of the users per session.

Andrew Backer

unread,
Aug 21, 2016, 10:54:58 PM8/21/16
to django-res...@googlegroups.com
At least for me, a google for "group-by/count with django" returns the answer as the first result.   DRF isn't responsible for the models and query part of this, so its really just a django question.

http://stackoverflow.com/questions/19101665/django-how-to-do-select-count-group-by-and-order-by

If there are DRF specific pieces like how to show it in a serializer, please post a followup.
August 20, 2016 at 7:03 AM
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages