Opened 6 years ago

Last modified 6 years ago

#29579 closed Bug

Objects count after Many to many related query shows wrong — at Version 1

Reported by: noufalvlpr Owned by: nobody
Component: Database layer (models, ORM) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by noufalvlpr)

class Standard(models.Model):
    name = models.CharField(max_length=30)
    created_at = models.DateField(null=True, blank=True)


class Product(models.Model):
    name = models.CharField(max_length=30, null=True)
    standards = models.ManyToManyField(Standard, related_name='products')

created standards with created_at=Null, added some standards to product and after

Product.objects.count()  # 6
Product.objects.filter(standards__created_at__isnull=True).count()  # 7

Change History (1)

comment:1 by noufalvlpr, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top