def get_models(): result = [] apps = Apps(settings.INSTALLED_APPS) for app_config in apps.get_app_configs(): try: import_module('%s.comments' % app_config.module.__name__) except ImportError: pass except Exception as e: raise e for attr_name in dir(app_config.models_module): attr = getattr(app_config.models_module, attr_name) if isinstance(attr, ModelBase) and attr.__module__ == '%s.models' % app_config.module.__name__: result.append(attr) return result
def get_models(): result = [] apps = Apps(settings.INSTALLED_APPS) for app_config in apps.get_app_configs(): try: import_module('%s.comments' % app_config.module.__name__) except ImportError: pass except Exception as e: raise e for attr_name in dir(app_config.models_module): attr = getattr(app_config.models_module, attr_name) if isinstance( attr, ModelBase ) and attr.__module__ == '%s.models' % app_config.module.__name__: result.append(attr) return result