Django-tenant-schemas 和 GeoDjango 在一起

Django-tenant-schemas and GeoDjango together

我想在我的 Django 项目中使用 django-tenant-schemas and GeoDjango (PostGIS)。我有一个默认数据库。但是 django-tenant-schemas 和 GeoDjango 都希望我在设置中为数据库设置自定义引擎。

django-tenant-schemas 希望将其设置为 tenant_schemas.postgresql_backend
而 GeoDjango 希望将其设置为 django.contrib.gis.db.backends.postgis

这个问题有解决办法吗?

编辑:我只想将 GeoDjango 用于单个模型,并且我正在使用单个 Postgres 数据库。

我解决这个问题的方法是在 tenant_schame.postgresql_backend.base 中更改 ORIGINAL_BACKEND。我把它改成了

ORIGINAL_BACKEND = getattr(settings, 'ORIGINAL_BACKEND', 'django.contrib.gis.db.backends.postgis')

来自

ORIGINAL_BACKEND = getattr(settings, 'ORIGINAL_BACKEND', 'django.db.backends.postgresql_psycopg2')