Paginate relationships - is it possible?

16 views
Skip to first unread message

David Binetti

unread,
Mar 23, 2018, 3:14:14 PM3/23/18
to Django REST framework
I have a model with a has-many relationship.  In most cases, the parent has only a few children -- less than a dozen, so returning related records is handled quite elegantly by the normal approach.

However, I have a handful of those models which have tens of thousands of children.  Obviously this breaks everything.  Now were I returning this as a list I'd simply paginate the results; is there a way to do that with related resources?

I'm also happy to basically skip the serializer/view queryset for those records, or to arbitrarily limit them to some small number (trying to slice the query set manually doesn't work because there is no longer a query set.  sigh)

anyway, hoping for some guidance.  I can't believe I'm the first to have encountered this problem by hours of searching are going nowhere...
Reply all
Reply to author
Forward
0 new messages