Django:如何重新启动网络服务器,以便应用源代码中的更改 [英] Django: How to restart webserver so that changes in sourcecode get applied

查看:134
本文介绍了Django:如何重新启动网络服务器,以便应用源代码中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Eclipse与PyDev结合使用来开发Django Web应用程序。我可以使用

  python manage.py runserver 


然后可以在浏览器中本地测试Web应用程序。但是,每次更改源代码时,都必须重新启动eclipse,以便将这些更改应用到我的Web应用程序中。



我想我必须以某种方式重新启动Web服务器,以便我的sourceode再次解释,以便我的更改得到应用。但是我该怎么做呢?我找不到执行此操作的任何命令。

解决方案

Django开发服务器会在python代码更改时自行重新启动它。如果使用noreload选项运行它,则可能不会出现此问题。



./ manage.py runserver --noreload



不自动重新加载服务器的另一种情况是django不使用文件更改时的情况。例如,如果您的admin.py django中有语法错误,则不会使用它。更改它不会重新启动服务器。
请记住,如果使用eclipse调试,则必须使用noreload运行django,因为该错误不会重新启动实例,但会启动新实例。


I using Eclipse with PyDev to develop Django Webapplication. I can start my webserver with

python manage.py runserver

and then I can test my webapplication locally in my browser. However everytime I change the sourcecode I have to restart eclipse so that these changes get applied in my webapplication.

I guess I have to somehow restart the webserver so that my sourceode gets interpreted again so that my changes get applied. But how do I do that? I couldnt find any command to do so.

解决方案

Django dev server restarts it self when python code changes. This may not happed if you run it with noreload option

./manage.py runserver --noreload

Another case when the server is not reloaded automatically is when the files changes is not used by django. For example if you have syntax error in your admin.py django won't use it. And changing it won't restart the server. Have in mind that if you use eclipse debug you will have to run django with noreload because of an bug that does not relaunch the instance but starts a new one.

这篇关于Django:如何重新启动网络服务器,以便应用源代码中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆