mik3y / django-db-multitenant

A simple multi-tenancy solution for Django apps.
Other
155 stars 34 forks source link

Removing the necessity for TENANT_DATABASE_NAME in settings.py #6

Closed alexandervaneck closed 7 years ago

alexandervaneck commented 8 years ago

Hi,

At the moment TENANT_DATABASE_NAME=example.com ./manage.py runserver doesn't work because django loads the settings after it tries to connect to mysql. This can be fixed by adding

python from db_multitenant.utils import update_database_from_env

if not dbname: utils.update_database_from_env(super(DatabaseWrapper, self).get_connection_params()) dbname = self.threadlocal.get_dbname()



to _cursor() between line 51 and 52 in db/backends/mysql/base.py.
alexandervaneck commented 8 years ago

Next to that:

python from django.utils.importlib import import_module


should be replaced with:

``` python```
from importlib import import_module

in both db/backend/mysql/base.py and utils.py to make this ready for Django 1.9.

Thanks for making this! :) works great

mik3y commented 7 years ago

Thanks for the update, and sorry for the neglect. This should be fixed thanks to #8, cheers.