我有以下幾個排除方式,可以帶回所有在過去兩分鐘內有交易的圖書。我想添加另一個約束,只有在來自一系列商店的情況下才會這樣說。如何在django中添加OR約束來排除查詢?
在SQL這將是其中LOCATION_ID = 1或LOCATION_ID = 2或LOCATION_ID = 3本
書籍有LOCATION_ID
如何申請,爲下面的查詢?
transaction_window = timezone.now() + datetime.timedelta(minutes=-2)
ts = Book.objects.exclude(book_id__in = Status.objects
.filter(transaction_time__gte=transaction_window)
.values_list('book_id', flat=True))
'Book.objects.exclude(status__transaction_time__gte = transaction_window)' –