Django rest framework Djangorest框架不反映资源的变化
当我使用json格式的curl对基于django rest框架的web服务执行一些post/patch请求时,我可以在管理页面和数据库中看到更改,但需要一些时间才能在API中反映该数字(GET请求)Django rest framework Djangorest框架不反映资源的变化,django-rest-framework,Django Rest Framework,当我使用json格式的curl对基于django rest框架的web服务执行一些post/patch请求时,我可以在管理页面和数据库中看到更改,但需要一些时间才能在API中反映该数字(GET请求) 先谢谢你 还要确保您的中间件是中间件类中的最后一个。 根据django源代码中的文档: django.middleware.cache.py(django版本1.5) 希望这有帮助这里没有足够的信息:您使用的是什么DBMS?哪个操作系统?您正在运行django开发web服务器吗?生产web服务器?哪
先谢谢你 还要确保您的中间件是中间件类中的最后一个。 根据django源代码中的文档: django.middleware.cache.py(django版本1.5)
希望这有帮助这里没有足够的信息:您使用的是什么DBMS?哪个操作系统?您正在运行django开发web服务器吗?生产web服务器?哪一个?中间件配置中有什么?谢谢Jeff的提示。这个问题与“django.middleware.cache.UpdateChemiddleware”有关,我很高兴你找到了它。
class UpdateCacheMiddleware(object):
"""
Response-phase cache middleware that updates the cache if the response is
cacheable.
Must be used as part of the two-part update/fetch cache middleware.
UpdateCacheMiddleware must be the first piece of middleware in
MIDDLEWARE_CLASSES so that it'll get called last during the response phase.
"""
# -- snip --
class FetchFromCacheMiddleware(object):
"""
Request-phase cache middleware that fetches a page from the cache.
Must be used as part of the two-part update/fetch cache middleware.
FetchFromCacheMiddleware must be the last piece of middleware in
MIDDLEWARE_CLASSES so that it'll get called last during the request phase.
"""
# -- snip --
class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
"""
Cache middleware that provides basic behavior for many simple sites.
Also used as the hook point for the cache decorator, which is generated
using the decorator-from-middleware utility.
"""
# -- snip --