Giter Site home page Giter Site logo

How to query value in list? about lifter HOT 3 OPEN

agateblue avatar agateblue commented on September 2, 2024
How to query value in list?

from lifter.

Comments (3)

agateblue avatar agateblue commented on September 2, 2024

Hello and sorry for my late answer, I was actually in a vacation trip :)

You can indeed use in, but with the myfield__value_in lookup:

objects.filter(eye_color__value_in=['brown'])

The fact is Python does not allows to override the __contains__ to return a non-boolean value. This is quite strange, considering you can do this for other lookups such as __eq__.

If you want to combine queries, you can also use the value_in operator object directly:

sent_folders = ['folder1', 'folder2']
query = Message.folder.test(lifter.lookups.value_in(sent_folders))

Also, as in is a registered keyword in python, for internal reasons, so that's why the lookup is named value_in instead of simply in.

The API is really not great here sorry :/

from lifter.

n3storm avatar n3storm commented on September 2, 2024

Thank you!

I am thinking how to add this information improved with extra expressions like contains etc to the docs. Could you please keep this issue open meanwhile?

from lifter.

agateblue avatar agateblue commented on September 2, 2024

Sure, that would be a great addition. Feel free to provide a PR whenever you have the time :)

from lifter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.