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'

posted @ 2020-06-24 09:59  Fmaj-7  阅读(307)  评论(0编辑  收藏  举报