我已经成功地使用 Django
、Nginx
、uWSGI
和 MySQL
开始了一个项目。
Django从MySQL中获取数据并渲染到页面,但是当我在MySQL中更改数据时,即使多次刷新也不会在页面上显示更改的数据。
问题来自于研究Django缓存。 我不知道如何测试 Django 缓存是否有效?
uwsgi:
[uwsgi]
vhost = false
plugins = python
socket = 127.0.0.1:8444
master = true
enable-threads = true
workers = 1
wsgi-file = project0/wsgi.py
chdir = /home/www/project0
touch-reload=/home/www/project0/reload
views.py
from django.shortcuts import render
from apps.blog.models import Timetest
timetest=Timetest.objects.get(id=1)
def index(req):
content="welcome"
return render(req,"blog/index.html",{"timetest":timetest})
博客/index.html
{{ timetest }}
最佳答案
将 timetest=Timetest.objects.get(id=1)
移动到您的 index
函数
def index(req):
content = "welcome"
timetest = Timetest.objects.get(id=1)
return render(req, "blog/index.html", {"timetest": timetest})
关于mysql - 为什么直接在MySQL中修改数据后页面内容不刷新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34578975/