#18878: syncdb for secondary non-default database generates error due to django_content_type --------------------------------------------+-------------------- Reporter: robertpayne@… | Owner: nobody Type: Bug | Status: new Component: Core (Management commands) | Version: 1.4 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 1 | UI/UX: 0 --------------------------------------------+-------------------- This is against Django 1.4.1
If you configure multiple databases in settings like such: {{{ DATABASES = { 'production': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'XXX_pro', 'USER': 'XXX', 'PASSWORD': 'satmed88', 'HOST': 'localhost', 'PORT': '3306', }, 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'XXX_dev', 'USER': 'XXX', 'PASSWORD': 'XXX', 'HOST': 'localhost', 'PORT': '3306', }, 'test': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'XXX_test', 'USER': 'XXX', 'PASSWORD': 'XXX', 'HOST': 'localhost', 'PORT': '3306', }, } }}} Then you run {{{ manage.py syncdb --database=production }}} it will fail with an error django.db.utils.DatabaseError: (1146, "Table 'XXX_dev.django_content_type' doesn't exist") Here is what I believe is happening: 1) django.core.management.syncdb.py runs 2) django.core.management.syncdb.py hits line 106 and commits a transaction {{{ transaction.commit_unless_managed(using=db) }}} 3) django.core.management.syncdb.py hits line 110 and fires post_sync_signal {{{ emit_post_sync_signal(created_models, verbosity, interactive, db) }}} 4) django.contrib.contentypes.management.py handles this post_sync_signal and while it does receive the selected db in the kwargs it never uses the db but just runs against the default routed database. Simple fix would be to patch django.contrib.contentypes.management.py to use the kwarg['db'] -- Ticket URL: <https://code.djangoproject.com/ticket/18878> 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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.