ivelum / djangoql

Advanced search language for Django
MIT License
997 stars 88 forks source link

Add operator to limit result count #56

Open jbanning-oreilly opened 4 years ago

jbanning-oreilly commented 4 years ago

Currently the limits for query results are set by Django admin pagination, with the option to "select all" across the pages when performing an action on the results. Some actions have limits of their own, so the "select all" group is too big, but the default pagination size of 100 results means having to manually loop through select 100, apply action, select next 100, [...] until the action has been applied to the full set.

Could a djangoql operator be added which can set a limit on the number of returned rows? Something exactly like the SQL "LIMIT" would be ideal.

Thanks!

stebunovd commented 4 years ago

Hi @jbanning-oreilly,

thank you for the idea, and I understand the use case and problem that you're facing. I'm not sure that it would be feasible to solve it with DjangoQL though. DjangoQL operates on the queryset level, and its result is a standard Django queryset. Of course, it's possible to apply slicing to a queryset, and that would probably fit into the current implementation model. However, it won't affect the way how Django does its pagination. I.e., it would shrink the resulting queryset, and you'll see fewer pages, but it won't affect the items per page setting, which is specific to Django admin.

I suppose that maybe the problem could be solved differently. There's a built-in setting in Django for items per page configuration. If you'd like it to be configurable directly from the user interface, it could be possible, I guess, and it might be a useful addition for all Django users, not just DjangoQL users. However, separate research is needed on this topic, and probably a solution will not be connected to DjangoQL.

thanks,

Denis