#18360: Database router example improvement
-------------------------------------+-------------------------------------
Reporter: sbaechler | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: 1.4
Component: Documentation | Resolution: invalid
Severity: Normal | Triage Stage:
Keywords: multiple database | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by russellm):
* status: new => closed
* resolution: => invalid
Comment:
I'm not sure I understand your report here.
The example is a specific demonstration of what you would do if "you want
myapp to exist on the other database, and you want all other models in a
master/slave relationship between the databases master, slave1 and
slave2"; This is exactly what the provided router implements.
MyAppRouter.allow_syncdb returns:
* True if you're synchronising the other database, and it is asked about
a model from myapp
* False if you're synchronising the other database, and it is asked about
a model that *isn't* from myapp
* False if you're synchronizing a database that isn't 'other', and it is
asked about a model from myapp
* Don't care otherwise.
Your code starts to introduce "myotherapp" -- i.e., an app that isn't
"myapp" -- which, by the original problem definition, should *not* be
synchronised onto 'other'. That doesn't mean that myotherapp can't
*access* other -- just that the models from myotherapp won't be
synchronised onto other. myotherapp can still access myapp.MyModel without
any problem.
You said: "If you have several app accessing the 'other' database". This
is in direct conflict with the stated problem that MyAppRouter is trying
to solve.
You then clarified with "there can only be one router per db". I have no
idea why you are making this assertion -- the example in the docs clearly
uses 2 routers, and works fine AFAICT.
Marking invalid; if I've misunderstood your report, feel free to reopen
with more details. However, keep in mind that all we're trying to do here
is provide an indicative problem, not provide a solution to every problem.
--
Ticket URL: <https://code.djangoproject.com/ticket/18360#comment:2>
Django <https://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.