Make a django query with a list of parameter [duplicate]
This question already has an answer here:
django filter with list of values
3 answers
i have a list of id like :
ids = [1,2,3]
Is there a quicker way to do a query for all of them than a for ?
Like:
users =
for id in ids :
users.append(User.objects.get(id=id))
thanks
python django django-queryset
marked as duplicate by Community♦ Nov 14 '18 at 19:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
django filter with list of values
3 answers
i have a list of id like :
ids = [1,2,3]
Is there a quicker way to do a query for all of them than a for ?
Like:
users =
for id in ids :
users.append(User.objects.get(id=id))
thanks
python django django-queryset
marked as duplicate by Community♦ Nov 14 '18 at 19:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
django filter with list of values
3 answers
i have a list of id like :
ids = [1,2,3]
Is there a quicker way to do a query for all of them than a for ?
Like:
users =
for id in ids :
users.append(User.objects.get(id=id))
thanks
python django django-queryset
This question already has an answer here:
django filter with list of values
3 answers
i have a list of id like :
ids = [1,2,3]
Is there a quicker way to do a query for all of them than a for ?
Like:
users =
for id in ids :
users.append(User.objects.get(id=id))
thanks
This question already has an answer here:
django filter with list of values
3 answers
python django django-queryset
python django django-queryset
asked Nov 14 '18 at 14:24
user462794user462794
21631950
21631950
marked as duplicate by Community♦ Nov 14 '18 at 19:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Community♦ Nov 14 '18 at 19:07
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Yes, use the __in filter function:
users = User.objects.filter(id__in=ids)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes, use the __in filter function:
users = User.objects.filter(id__in=ids)
add a comment |
Yes, use the __in filter function:
users = User.objects.filter(id__in=ids)
add a comment |
Yes, use the __in filter function:
users = User.objects.filter(id__in=ids)
Yes, use the __in filter function:
users = User.objects.filter(id__in=ids)
edited Nov 14 '18 at 15:21
answered Nov 14 '18 at 14:25
schwobasegglschwobaseggl
37.2k32442
37.2k32442
add a comment |
add a comment |