【发布时间】:2016-07-20 02:45:15
【问题描述】:
修改后的inspectdb,我想在加载网页索引页面时运行它。所以,在我的 view.py - def index 中,我正在尝试做下一个:
def index(request):
subprocess.Popen("rm /path/app/models.py", shell=True)
subprocess.Popen("python2.7 /path/manage.py inspectdb_New > /path/app/models.py", shell=True)
return render_to_response('index/index.html', context_instance = RequestContext(request))
这是行不通的。我也尝试过使用 os.system、subprocess.call,但它仍然无法正常工作。 至少对我来说,看起来我无法在执行时修改 models.py,但我不知道可能是什么问题......
有什么想法吗?
谢谢。
【问题讨论】:
标签: python django python-2.7 django-models django-views