[Answered ]-Queryset Cannot reorder a query once a slice has been taken

1👍

This Error is happening after queryset is returned by the get_queryset, since LocationViewSet has ‘ordering’ attribute which tries to re-oder the queryset again.

👤Bradia

1👍

You can write raw query for 10 result in your code like that it will work,

org = Organization.objects.raw('SELECT organization_id, name FROM organization where is_active=1 ORDER BY name limit 10')

Keep one thing in a raw query you have to always fetch primary key of table, it’s mandatory. Here organization_id is a primary key of contact_organization table.

Leave a comment