#13358 closed (fixed)
RelatedManager does not work with db_manager
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2-beta |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
RelatedManager is always selecting from the db_for_read provided by the router even if db_manager() is used.
With the following models:
class ModelA(models.Model): foo = models.IntegerField(default=0) class ModelB(models.Model): bar = models.ManyToManyField(ModelA)
Running the following in shell:
>>> mod_a = ModelA.objects.create(foo=1) >>> mod_b = ModelB.objects.create() >>> mod_b.bar.add(mod_a) >>> mod_a.modelb_set <django.db.models.fields.related.ManyRelatedManager object at 0x102b4da50 >>> mod_a.modelb_set.db 'default_slave' >>> mod_a.modelb_set.db_manager('default').db 'default' >>> mod_a.modelb_set.db_manager('default').all()[0]._state.db 'default_slave'
Change History (3)
comment:1 by , 15 years ago
milestone: | → 1.2 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
For the record, it also affects reverse FK relations.