I have two models, let's say:
class Order(models.Model):
# ... fields
class Product(models.Model):
quantity = models.PositiveIntegerField(null=False, blank=False, default=1)
order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='products')
b_product = models.ForeignKey(BaseProduct, null=False, blank=False, on_delete=models.CASCADE)
class BaseProduct(models.Model):
type = #.... choices = [rtProduct, rtPack]
I want to make a query that includes all the Orders which have more than one Product related to it, or if at least one Product has a quantity greater than 1, or if the BaseProduct type is rtProduct
For the first part I have this:
queryset = Order.objects.annotate(products_count=Count('products')).filter(products_count__gt=1)
I am stuck on adding the OR condition to also include the other condition.
Thank you so much in advance.