Opened 2 years ago

Last modified 8 months ago

#25367 new Cleanup/optimization

Allow expressions in .filter() calls

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: me@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


Expressions in filter calls will allow 3rd party apps to create query syntax extensions (for example .filter(F('some_field').lower() == 'anssi')) style). In addition, having the ability to use expressions everywhere unifies the ORM experience.

Change History (4)

comment:1 Changed 2 years ago by Tim Graham

Keywords: 1.9 added

comment:2 Changed 2 years ago by Adam (Chainz) Johnson

Cc: me@… added

This would also probably allow extra(where) to be removed as discussed on!topic/django-developers/FojuU0syO8Y , if expressions with 0 column references are allowed.

comment:3 Changed 2 years ago by Tim Graham

Keywords: 1.9 removed

As noted on the pull request, there are some problems that can't be solved in time for the 1.9 freeze.

comment:4 Changed 8 months ago by Matthew Schinckel

I have a PR that addresses part of this: being able to have an expression that returns a value with an output_field of BooleanField used in a .filter(), or a Case(When(...)) situation.

Does this address enough of this ticket? Or provide any other suggestions?

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