Reputation: 67
I'm trying to get the first document with a non null value in given attribute. For example, in the db the collection Fruit looks like this:
Banana:
weight: null
colour: yellow
Apple:
weight: 100
colour: green
I want my query to return the apple document because its weight a valid value. I tried
Fruit.objects.get(weight is not None).first()
but when running my query with postman I get the error:
Not a query object: True. Did you intend to use key=value?
How can I achieve this ?
Upvotes: 0
Views: 187