1
在我的一些django实用程序类中,我想定义一个主要方法,以便我可以调用我的模块而不必使用shell。 (致电)这甚至有可能吗?如果是这样,我怎么能打这个电话?不带壳的调用模块
from django.conf import settings
... # Define module code here
if __name__ == "__main__":
print(settings.DEBUG)
# interact with classes defined in this module which require django classes
编写自定义[django-admin命令](https://docs.djangoproject.com/en/1.5/howto/custom-management-commands/)。 – falsetru
add'sys.path.append(“/ path/to/MyModule.py”)'那么你可以'导入MyModule' – Stephen