#12587: Related fields when using multiple databases and different managers
------------------------------------------+---------------------------------
Reporter: aprilmay | Owner: nobody
Status: new | Milestone: 1.2
Component: Database layer (models, ORM) | Version: SVN
Keywords: multiple related | Stage: Unreviewed
Has_patch: 1 |
------------------------------------------+---------------------------------
Let's take the case:
- 2 databases in settings.py (default and otherdb)
- 2 model managers, that will be used for managing models on different
DBs:
{{{
class Manager1(models.Manager):
def __init__(self):
super(Manager1, self).__init__()
self._db = 'default'
class Manager2(models.Manager):
def __init__(self):
super(Manager2, self).__init__()
self._db = 'otherdb'
}}}
- 2 models using a manager each, and a relation between the 2:
{{{
class MyModel1(models.Model):
objects = Manager1()
class MyModel2(models.Model):
objects = Manager2()
rel_to_model1 = models.OneToOneField(MyModel1)
}}}
In that case the relations fail:
{{{
a_model2 = MyModel2.objects.all()[0]
a_model1 = a_model2.rel_to_model1
}}}
The last line raises an error because it uses the manager for model2 for
searching model1.
Also,
{{{
a_model1 = MyModel1.objects.all()[0]
a_model2 = a_model1.mymodel2
}}}
The last line raises an error for the same reason than above.
These examples show (and the proposed patch is a fix for) the
OneToOneField relation, but other relations might suffer from same kind of
issue.
This is dummy code, hope it is good enough.
--
Ticket URL: <http://code.djangoproject.com/ticket/12587>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.