citusdata / django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus
MIT License
721 stars 119 forks source link

ImportError: No module named django_multitenant #10

Closed salmanqureshi closed 5 years ago

salmanqureshi commented 6 years ago

New to Python/Django and only reporting this because I am not sure if there's something wrong with my setup or just how the plugin/package is packaged/distributed.

I have a virtual environment with .. python 2.7 and django 1.11

Installed the package using 'pip install django_multitenant', but ran into an ImportError because of the line "from django_multitenant.django_multitenant import *", which wasn't in my code. I had to refactor the init.py and remove the redundant django_multitenant from the import to fix this.

Is this the right approach? Or is there a distribution available with the fix? I don't want everyone in the team to have to do this.

saicitus commented 6 years ago

Hey @salmanqureshi, with this commit I fixed it and pushed a new release in pypi repository. Could be that you have an older release, could you try to uninstall and reinstall the library.

salmanqureshi commented 6 years ago

I installed the package a few hours before reporting the issue. And see the version installed as 1.0.2. The commit you referred to is actually 1.0.1 and the line added to init.py is what I had to fix.

At the moment init.py and django_multitenant.py are at the same level. Should the plugin code have been inside a directory?

saicitus commented 6 years ago

Looks like this is happening with python 2.x version. With python 3.6 it doesn't because I guess it recursively picking up the library via the high level django_multitenant folder.

One thing you could try is keep the same init.py and have something as below in the files you want to use the library:

import django_multitenant
from django_multitenant import *
salmanqureshi commented 6 years ago

No luck. I'll go ahead with editing the module init file for now.

mehta commented 6 years ago

Issue resolved in this - https://github.com/mehta/django-multitenant

louiseGrandjonc commented 5 years ago

Hi @mehta, @salmanqureshi, I wanted to let you know that a new version of django_multitenant was released which could also be solving the issue that you had :)