id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 28499 makemigrations fails on model with geometry field when the geo database is not the default one Kaveh nobody "Create a django app with two databases defined like this: {{{ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'whatever' ... }, 'postgres': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'whatever' } } }}} and here is the database router: {{{ POSTGRES_APPS = ['app1'] class PostgresRouter(object): def db_for_read(self, model, **hints): if model._meta.app_label in POSTGRES_APPS: return 'postgres' return None def db_for_write(self, model, **hints): if model._meta.app_label in POSTGRES_APPS: return 'postgres' return None def allow_relation(self, obj1, obj2, **hints): if {obj1._meta.app_label, obj2._meta.app_label}.issubset(set(POSTGRES_APPS)): return True return None def allow_migrate(self, db, app_label, model_name=None, **hints): if db == 'postgres': return app_label in POSTGRES_APPS else: return app_label not in POSTGRES_APPS }}} Create an app called `app1` and add it to `INSTALLED_APPS`: {{{ class Shapes(models.Model): shape = models.GeometryField() }}} Now if you run `makemigrations`, it throws the following error: `AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'` Seems like the error is because Django is using the default connection, i.e. mysql, for handling the geomtry field in app1, though this app is supposed to be part of the gis enabled database, i.e. postgres. " Bug closed GIS 1.8 Normal fixed Unreviewed 0 0 0 0 0 0