Closed agateblue closed 8 years ago
+1
It would be good to have the opposite filter also, ie: User.optional_field.does_no_exist()
.
I wonder if optional_field is not None
(since people are used to dict.get returning None if the lookup fails) or optional_field is Exists
would make sense.
I don't like the idea of created two methods, instead, you can use the ~
operator, that inverts a query (this work with any query ;).
Filter objects with the field:
manager.filter(Model.optional_field.exists())
Filter objects without the field:
manager.filter(~Model.optional_field.exists())
Currently, if you query on a field that do not exist on all models, lifter will raise an error. Making this behaviour optional, would be an improvement. Example:
This was first raised on reddit