@@ -0,0 +1,1393 @@
+# __init__.py%0A%0A## This module is so that all plugins can have custom models.py files in%0A## their own folders and have them picked up with %0A## $ python manage.py syncdb%0A%0Aimport inspect%0Aimport os%0Afrom django.conf import settings%0Afrom django.db import models%0A%0A### Import all the model modules from plugins/  ###%0A__all__ = %5B%5D%0A%0Aplugin_path = os.path.join(settings.BASE_DIR, 'plugins')%0Adirs = os.gitlistdir(plugin_path)%0Afor m in dirs:%0A    pth = os.path.join(plugin_path, m)%0A    model_pth = os.path.join(pth, %22models.py%22)%0A    if os.path.isdir(pth) and os.path.isfile(model_pth):%0A        mod = 'plugins.'+m+'.models'%0A#            print('importing module '+'plugins.'+m)%0A%0A        imp_mod = __import__(mod)%0A        %0A        m1 = getattr(__import__(mod), m)%0A        m2 = getattr(m1, %22models%22)%0A        %0A        for attr in dir(m2):%0A            a1 = getattr(m2, attr)%0A            # Check if the class is a class derived from %0A            # bot.PluginDespatch.Plugin%0A            # but is not the base class only%0A%0A            if inspect.isclass(a1) and %5C%0A            a1 != models.Model and %5C%0A            issubclass(a1, models.Model):%0A%0A                from_path = %22plugins.%22+m+%22.models%22%0A%0A#                    print('from %7B%7D import %7B%7D'.format(from_path, a1.__name__))%0A                globals()%5Ba1.__name__%5D = a1%0A                __all__.append(a1.__name__)%0A%0A%0A%0A###  ====  End plugin models modules Import === ###

Allow plugins to have models.py files in their own plugin folders