#18360: Database router example improvement
--------------------------------------+-------------------------------
Reporter: sbaechler | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Keywords: multiple database
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+-------------------------------
In your example for a database router on
https://docs.djangoproject.com/en/1.4/topics/db/multi-db/ there is one
problem:
If you have several app accessing the 'other' database and multiple
routers, the syncdb will not work for any app but the first one.
Currently it is:
{{{
class MyAppRouter(object):
def allow_syncdb(self, db, model):
"Make sure the myapp app only appears on the 'other' db"
if db == 'other':
return model._meta.app_label == 'myapp'
elif model._meta.app_label == 'myapp':
return False
return None
}}}
If the database is 'other' and the app_label is not 'myapp' the router
returns False and syncdb won't work for all other routers for this db.
A better example would be:
{{{
def allow_syncdb(self, db, model):
if db == 'other' and model._meta.app_label == 'myapp':
return True
elif model._meta.app_label == 'myapp':
return False
return None
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18360>
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.