Django 重新启动服务器或 httpd
在django框架中,当urls.py或model.py或views.py发生变化时,我们会重新启动httpd。
但正如文档所说,我们可以重新启动 runserver 以获取最新的更改。
这是执行上述操作的最有效方法
In django framework,When there are changes in urls.py or model.py or views.py .We would restart httpd.
But as the documentation says we could restart runserver to get the latest changes.
Which is the best efficient way for doing the above
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
每次修改任何 .py 文件时,runserver.py 都会自动重新启动,但是当您使用 apache 时,您必须手动重新启动该进程。
runserver.py restarts automatically every time you modify any .py file, but when you are using apache you have to restart the proccess manually.
触摸 your_project_name.wsgi
并保存,不进行任何更改。它会改变数据修改,django会自动重新加载代码。
touch your_project_name.wsgi
and save without any change.It will change data modify and django will automatically reloading code.
runserver
指的是随Django一起发布的开发服务器。重新启动此服务器或您的 httpd 是同一件事,在这两种情况下都重新启动网络服务器。如果您使用的是 apache,则您没有使用由runserver.py
启动的开发服务器。runserver
refers to the development server that is distributed with Django. Restarting this one or your httpd are the same thing, in both cases you restart the webserver. If you're using apache, you are not using the development server that is startet byrunserver.py
.在终端中输入
fg
以获取作业,然后输入Ctr+c
停止服务器,然后运行Type
fg
in terminal to take job front and then typeCtr+c
to stop server and then run对于开发服务器,我添加了这个非常方便的功能。显然,你不应该把它留在产品中。
_thread.interrupt_main() 模拟键盘中断 (SIGINT)。
For the development server, I added this very convenient function. Obviously, you should never leave this in prod.
_thread.interrupt_main() simulates a KeyboardInterrupt (SIGINT).