hi list,

checked out the new multidb feature
(http://docs.djangoproject.com/en/dev/topics/db/multi-db/).

i assumed that syncdb would only sync those models in the database
when calling allow_syncdb() of the database routers return True. is
that true?

my problem: syncdb syncs the complete model in the db. and i couldnt
even figure out if the DATABASE_ROUTERS are correctly configured and
working (django don't throws an error if the DATABASE_ROUTERS =
['foo.bar'])

### Django version 1.2 alpha 1 SVN-12120

### project/settings.py
DATABASES = {
    'default': {
        'NAME': 'multidb_app2009',
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'root',
        'PASSWORD': 'root'
    },
    'users': {
        'NAME': 'multidb_user',
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'root',
        'PASSWORD': 'root'
    }
}

DATABASE_ROUTERS = ['dbrouter.AuthRouter', 'dbrouter.OtherRouter']


### project/dbrouter.py

# coding: utf-8

class AuthRouter(object):
    """A router to control all database operations on models in
    the contrib.auth application"""

    ....

    def allow_syncdb(self, db, model):
        "Make sure the auth app only appears on the 'credentials' db"
        if db == 'users':
            return model._meta.app_label == 'auth'
        elif model._meta.app_label == 'auth':
            return False
        return None


class OtherRouter(object):
    """A router that sets up a simple master/slave configuration"""

    ...

    def allow_syncdb(self, db, model):
        "Explicitly put all models on all databases."
        return True


thx for your help,
-- 
klemens mantzos
http://fetzig.at/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to