Django开发服务器未检测到我的html文件中的更改 [英] Django Development server doesn't detect changes in my html files

查看:48
本文介绍了Django开发服务器未检测到我的html文件中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用django 1.7.5.我在我的项目中使用了vagrant和virtual box.我成功运行了服务器并在浏览器上检测到更改.但是,问题是在html文件中进行了任何更改之后,我必须重新启动服务器才能在浏览器上查看更改.

I am using django 1.7.5 for my project .I am using vagrant and virtual box for my project.I successfully ran the server and detected changes on my browser.But,the problem is After making any changes in the html file,I had to restart the server to see changes on the browser.

django 1.7.5是否在旅途中检测到更改?(例如进行更改文件,刷新浏览器,查看更改.)还是与Django版本无关?

Does django 1.7.5 detect changes on the go?(like make change the file,refresh the browser,see changes.) or this is not related to django version?

我的网站很旧.所以它使用1.7.5.如何在我的django 1.7.5版本中启用缓存.我在设置文件中找到了它.

My website is very old. so it uses 1.7.5.How to enable caching in my version of django 1.7.5. I got this in my settings file.

   CACHES = { 'default': { 'BACKEND': 

'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': 
os.environ.get('CACHES_DEFAULT_LOCATION', '127.0.0.1:11211') }
, 'social': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': os.environ.get('CACHES_SOCIAL_LOCATION', '127.0.0.1:11211') 
} }

编辑:我的问题可能是错误的.我在html文件中所做的更改未反映在浏览器上.它用于反映我何时从本地django运行示例项目(不使用virtualbox)

My question might be wrong specifically. The changes I made in the html file doesn't reflect on browser. It use to reflect when I run the example project from django locally (without using virtualbox)

推荐答案

Django会检测Python文件中的更改,但不会检测html文件中的更改,因为每次访问服务器时都会渲染这些更改(除非您启用了缓存)

Django detects changes in Python files, it does not detect changes in html files as those are rendered every time you access the server (unless you've enabled caching).

浏览器可能是造成这种情况的原因,因为它可能会缓存HTML文件,甚至无法访问服务器以再次获取它们.

The browser may be the cause of this, as it may cache HTML files and not even access the server to get them again.

顺便说一句,为什么不升级到最新的Django?1.7已经很老了.

By the way, why not upgrade to the latest Django? 1.7 is quite old.

这篇关于Django开发服务器未检测到我的html文件中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆