mik3y / django-db-multitenant

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

mappers is not working in subdirectories #17

Closed esclkm closed 6 years ago

esclkm commented 7 years ago

If i save my mapper in directory [app_config]\tenants\mapper - class Mapper

and in settings MULTITENANT_MAPPER_CLASS = '[app_config].tenants.mapper.Mapper'

I will have an error

"Could not import mapper:..." - utils.py line 71

may be you need to replace try constuction?

        try:
            module_path, member_name = name.rsplit(".", 1)
            module = import_module(module_path)
            cls = getattr(module, member_name)

to

        try:
            from pydoc import locate
            cls = locate(name)
stephane commented 6 years ago

I don't want to depend on pydoc. Maybe an issue without Python env (pip install . of your app), take care to provide the full Python path to the module.