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 )
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
Note:
See TracTickets
for help on using tickets.