Let\'s say I have a Product model with products in a storefront, and a ProductImages table with images of the product, which can have zero or more im
Product
ProductImages
Use conditional expressions and cast outputfield to BooleanField
Product.objects.annotate(image_count=Count('images')).annotate(has_image=Case(When(image_count=0, then=Value(False)), default=Value(True), output_field=BooleanField())).order_by('-has_image')