是否可以重新加载视图而不重新启动Django?

编程入门 行业动态 更新时间:2024-10-25 20:23:21
本文介绍了是否可以重新加载视图而不重新启动Django?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

再次更改没有运行服务器的视图功能后,按F5刷新页面,Django将不会重新加载新的视图,而是使用上一个视图。但是如果您更改模板,Django将始终使用新的模板。

After changing the view function without runserver again, and press F5 to refresh the page, Django will not reload the new view but use the previous one. but if you change the template, Django always uses the new one.

所以,有没有办法让Django每次刷新页面时重新加载视图,认为这是非常方便的开发来修改视图功能的频繁。

So, Is there a way to make Django reload the view every time the user refresh the page, I think that is very convenient for develop to modify the view function frequently.

推荐答案

如果你使用dev服务器运行django。 /manage.py runserver),那么当它检测到任何代码更改时,它将始终重新加载。这比每次请求重新加载更有效。如果您进行更改,则需要重新加载。

If you are running django using the dev server (./manage.py runserver) then it will always reload when it detects any code changes. This is even more efficient than reloading with every request. If you make a change, it reloads when it needs to.

如果您正在运行生产服务器(nginx,apache等),并且希望重新加载代码,那么您需要向您的wsgi模块添加一些东西来检测代码更改。

If you are running a production server (nginx, apache, etc) and you want code-reload, then you need to add something to your wsgi module to detect code changes.

使用apache重新加载代码:code.google/p/modwsgi/wiki/ReloadingSourceCode

Code reloading with apache: code.google/p/modwsgi/wiki/ReloadingSourceCode

使用uwsgi进行代码重新加载: projects.unbit.it/uwsgi/wiki/TipsAndTricks

Code reloading with uwsgi: projects.unbit.it/uwsgi/wiki/TipsAndTricks

更多推荐

是否可以重新加载视图而不重新启动Django?

本文发布于:2023-10-28 17:53:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537354.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不   视图   重新启动   加载   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!