1
我想在django中創建一個AND queryset。查詢是給所有客戶一定的ID。我有id存儲在python列表中。我最初的想法如下動態在django中創建「OR」查詢
ids = range(1,21)
specific_customers = []
customers = Customer.objects.all() //Get them all
for customer in customers:
if customer.pk in ids:
specific_customers.append(customer)
但我不認爲這是做到這一點的最佳方式。任何更好或更快的想法?
dammnnn !!!!!不知道django有這個東西!謝謝路德維克,救了我的一天! – Apostolos
當然,沒問題。如果答案解決了您的問題,您可能需要將其標記爲:) –
當然......這裏是您的標記! – Apostolos