gpt4 book ai didi

Django Server 不影响 View 变化

转载 作者:行者123 更新时间:2023-12-05 02:54:31 24 4
gpt4 key购买 nike

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

我配置了一切( like here )正常并且工作得很好,但我注意到我的 View 中的更改不会影响我的服务器端,尽管应用了模板更改。

这是我的场景:


第一次提交:

服务.views.py :

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

模板/bio.html :

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

第二次提交:

服务.views.py :

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

模板/bio.html :

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

我更改了 View 和模板并将它们拉到服务器。

所以现在,django 仍然呈现 'bio.html' (但它必须呈现 'student.html' ),有趣的是它显示 'student. lastName' 现在。

这意味着,django 看到我的模板更改但看不到更改。

我反复检查服务器上的一切是否正确,是的,所有代码都在服务器上正确,但不影响任何 View 更改,尽管我的所有模板更改都受到影响。

我还重启了nginx,还重启了好几次服务器。

这有什么问题????

最佳答案

我认为你需要重启 Gunicorn 和 Nginx

sudo systemctl restart gunicorn nginx

关于Django Server 不影响 View 变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61765390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com