S
S
Serj B2018-06-12 01:13:20
MySQL
Serj B, 2018-06-12 01:13:20

Django orm - how to select multiple values ​​of one field?

There is a generated list with a different number of elements (let's say): And there is a model (my_modql) with a column (color). How to select all rows whose color matches one of the list values?
color = ["red","green","yellow"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Malyarov, 2018-06-12
@Serj-B

Model.object.filter(color__in=["red","green","yellow"])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question