Commits

Peter Sanchez committed 11f6dc0

Fixed bug when importing class for config. Now works with class or base module import

Comments (0)

Files changed (1)

webutils/djtools/easyconfig.py

             path = '.'.join(config.split('.')[:-1])
             pkg = config.split('.')[-1]
             try:
-                package = import_module(path, package=pkg)
-            except ImportError:
+                tmp_package = import_module(path, package=pkg)
+                package = getattr(tmp_package, pkg)
+            except (ImportError, AttributeError):
                 raise ImproperlyConfigured(
                     'The %s setting refers to a non-existing package.' % \
                                                             self.setting_name
                 )
-
+        
+        if callable(package):
+            package = package()
         return package
 
     def _get_config_name(self):