Django服务器不影响视图的更改

问题描述 投票:0回答:1

我在Ubuntu 18.04上使用Nginx和Gunicorn来服务我的Django项目。

我配置了一切 (像这里) 但我注意到我的视图中的变化并没有影响到我的服务器端,尽管模板的变化被应用。

这是我的情况。


第一次提交 :

service.views.py :

def showSudent(req):
  student = Student.objects.get(pk=1)
  return render(req, 'bio.html, { 'student' : student} )

templatebio.html 。

<h3>{{ student.firstName }}</h3>

第二次提交。

service.views.py : templatebio.html : 第二次提交

def showSudent(req):
  student = Student.objects.get(pk=1)
  return render(req, 'student.html, { 'student' : student} )

templatebio.html 。

<h3>{{ student.lastName }}</h3>

我把views和template都改了,并把它们拉到服务器上。

所以,现在,django仍然是渲染''。生物.html'(但它必须渲染'。学生.html' ) ,到时候有趣的是它显示'学生。'了。

这意味着,django看到了我的模板变化,但没有看到视图的变化。

我反复检查了服务器上的一切正常,是的,所有的代码都在服务器上,但是没有影响任何视图的变化,尽管我所有的模板变化都受到影响。

我也重启了nginx,甚至重启了几次服务器。

这到底是什么问题呢?

django nginx deployment server gunicorn
1个回答
0
投票

我想你需要重新启动Gunicorn。

sudo systemctl restart gunicorn

0
投票

默认情况下,gunicorn需要手动重启应用程序,还有一个选项不适合在生产环境下运行gunicorn,它有以下功能 --reload 这样的参数。

$ gunicorn wsgi:application --reload

https:/docs.gunicorn.orgen19.0settings.html#reload。

© www.soinside.com 2019 - 2024. All rights reserved.