Opened 18 years ago
Closed 18 years ago
#4464 closed (fixed)
Chaining filters on ManyToManyFields broken?
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | manytomany, manytomanyfield, qs-rf-fixed | |
| Cc: | b-django@… | Triage Stage: | Accepted |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The last part of this fails (with MySql 5):
from django.db import models
class Category(models.Model):
name=models.CharField(maxlength=40)
class Thing(models.Model):
"""
>>> cat1 = Category.objects.create(name="cat2")
>>> cat1.save()
>>> cat2 = Category.objects.create(name="cat2")
>>> cat2.save()
>>> my_thing = Thing.objects.create(name="My thing")
>>> my_thing.save()
>>> my_thing.categories = [cat1, cat2]
>>> Thing.objects.filter(categories=cat1)
[<Thing: My thing>]
>>> Thing.objects.filter(categories=cat2)
[<Thing: My thing>]
>>> Thing.objects.filter(categories=cat1).filter(categories=cat2)
[<Thing: My thing>]
"""
name=models.CharField(maxlength=40)
categories = models.ManyToManyField(Category)
def __str__(self):
return self.name
Am I right in thinking that ought to pass?
Change History (4)
comment:1 by , 18 years ago
| Owner: | changed from to |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 18 years ago
| Cc: | added |
|---|
comment:3 by , 18 years ago
| Keywords: | qs-rf-fixed added |
|---|
comment:4 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
(In [7477]) Merged the queryset-refactor branch into trunk.
This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.
Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658
This is a dupe of something (I thought), but I can't find. It should work. I'm working on it.