multiple databases and syncdb problem

21 views
Skip to first unread message

Sells, Fred

unread,
Oct 29, 2013, 4:52:15 PM10/29/13
to django...@googlegroups.com

I can syncdb OK if I don’t add allow_syncdb to my router, but if I add the allow_syncdb to the router, only my default db is synced.  Any idea what I’m doing wrong, code is:

 

    def allow_syncdb(self, db, model):

        print 'allow syncdb for***************** Inserv Router', db, model._meta.app_label

        return db=='inserv' and model._meta.app_label == 'inserv'

 

Simon Charette

unread,
Oct 29, 2013, 5:35:41 PM10/29/13
to django...@googlegroups.com
syncdb defaults to syncing the 'default' database when no --database is specified.

Try specifying which database to synchronize, with the --database=inserv flag in your case.

Tom Evans

unread,
Oct 30, 2013, 5:47:42 AM10/30/13
to django...@googlegroups.com
On Tue, Oct 29, 2013 at 9:35 PM, Simon Charette <chare...@gmail.com> wrote:
> syncdb defaults to syncing the 'default' database when no --database is
> specified.
>
> Try specifying which database to synchronize, with the --database=inserv
> flag in your case.
>

syncdb will only synch one DB at a time, and as Simon says, it will
default to 'default' if you do not specify a database. If you have
multiple databases, you need to call syncdb once for each of them.

A warning, if you have South installed, syncdb gains a '--all'
argument; this does not synch to all databases, it synchs all apps,
even migrated ones, which is probably not what you want.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages