Opened 5 months ago

Last modified 5 months ago

#28087 new New feature

Allow filtering and ordering with RawQuerySet

Reported by: Dmitriy Sintsov Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I implemented FilteredRawQuerySet which wraps around RawQuerySet and uses QuerySet to generate WHERE / ORDER BY statements for raw queries:

https://github.com/Dmitri-Sintsov/django-jinja-knockout/blob/master/django_jinja_knockout/query.py

It works with Django 1.8 to 1.11, but I had to fix it when database queries code were refactored in Django 1.9. So I am worrying a bit that new modifications can break it again.

Such querysets are useful when someone uses RAW queryset with ListViews which automatically generate filter() / order_by() arguments.

There is also a ListQuerySet which allows to query Prefetch object results as normal querysets. That allows to re-use the same code for different related queries.

If that is possible, it would be great to move such feature into the core. If the code is not good enough, then it could be reviewed and improved by core committer - if someone is interested, of course.

Change History (1)

comment:1 Changed 5 months ago by Tim Graham

Summary: RawQuerySet with filtering and ordering.Allow filtering and ordering with RawQuerySet
Triage Stage: UnreviewedSomeday/Maybe

I'm not sure about this. Perhaps you could raise the idea on the DevelopersMailingList to get feedback from a wider audience.

Note: See TracTickets for help on using tickets.
Back to Top