Created
September 25, 2015 15:17
-
-
Save bplaxco/bc8511b90903efcfefb5 to your computer and use it in GitHub Desktop.
Revisions
-
bplaxco created this gist
Sep 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ # Import classes from files in the sub directory # so files in models/ClassName.py with ClassName in it # can be imported as models.ClassName import pkgutil __all__ = [] for _, name, ispkg in pkgutil.walk_packages(__path__): if not name.startswith('__') and not ispkg: # Ex: apps.assessment.models.<name> full_name = '.'.join([__name__, name]) # Get the module that is holding the class module = __import__(full_name, fromlist=[name]) # Get the class from the module and bring it into the global name space globals()[name] = getattr(module, name) # Add it to the __all__ array for * imports __all__.append(name)