django动态加载模块实例

1 def load_command_class(app_name, name):
2     """
3     Given a command name and an application name, returns the Command
4     class instance. All errors raised by the import process
5     (ImportError, AttributeError) are allowed to propagate.
6     """
7     module = import_module('%s.management.commands.%s' % (app_name, name))
8     return module.Command()

app_name = 'django.contrib.staticfiles

name = 'runserver'

原文地址:https://www.cnblogs.com/Fmaj7/p/13186031.html