本文介绍了是否可以重新加载视图而不重新启动Django?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 再次更改没有运行服务器的视图功能后,按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重新加载代码:http://code.google.com/p/modwsgi/wiki/ReloadingSourceCodeCode reloading with apache: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode使用uwsgi进行代码重新加载: http://projects.unbit.it/uwsgi/wiki/TipsAndTricksCode reloading with uwsgi: http://projects.unbit.it/uwsgi/wiki/TipsAndTricks 这篇关于是否可以重新加载视图而不重新启动Django?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-15 07:30