[Fixed]-Django .exclude() returning unexpected results

1👍

✅

The query you are executing means AND. That means that it will exclude sales_date less than date AND id is equal to instance.id.

If I understood it correctly, you can do it like this:

qs = self.model.objects.exclude(invoice__sale_date__lt=date).exclude(id=instance.id)

Leave a comment