问题
I have a problem with Django. Possibly with it's cache. Version 1.11
I use template in urlpatterns like :
urlpatterns = [
url(r'^service_preview/', include(serviceprev_urls, namespace = 'service_preview')),
url(r'^service_preview/',TemplateView.as_view(template_name='service_preview.html')),
]
After a lot of updates, applied to my template, the changes stop appearing in user's browser. I have actual template in my templates folder and some previous version when preview source code in browser. If I rename the template (this should raise error because template is absent), I still have that previous template in browser source. Browser page refreshing, clearing browser cache etc does not help. There are no duplicates of this page in my template folder.
When I use another template, all is ok. Possibly, problem is in django cache. I don't know how to force clear cache, maybe it would be a solution.
I put this at app setting file, but it doesn't help.
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache',}}
EDIT: i found i have duplicate html name, located in the same project, but other application's template directory. May it cause a problem
回答1:
By default, the Django template loader caches templates when DEBUG = False
. After changing a template, you need to restart the server (e.g. Apache or gunicorn) to see the changes. This behaviour is not affected by the CACHES
setting.
来源:https://stackoverflow.com/questions/51747782/django-template-is-not-changed-after-update-possible-cache