from django.conf.urls.defaults import url
from django.views.decorators.cache import never_cache
def never_cache_patterns(prefix, *args):
pattern_list = [], tterns,
for t in args:
if isinstance(t, (list, tuple)):
t = url(prefix=prefix, *t)
elif isinstance(t, RegexURLPattern):
t.add_prefix(prefix)
t._callback = never_cache(t.callback)
pattern_list.append(t)
return pattern_list
urlpatterns = never_cache_patterns('',
(r'foo/$', 'myview')
)
Apply a never_cache to a flatpage view
-
30-03-2022 - |
Pergunta
I want to create a home view that is the same as a home view but does not cache it.
urlpatterns += patterns('django.contrib.flatpages.views',
url(r'^$', 'flatpage', {'url': '/'}, name='home'),
)
Something like this
urlpatterns += patterns('django.contrib.flatpages.views',
url(r'^$', 'flatpage', {'url': '/'}, name='home'),
url(r'^new/$', never_cache('flatpage', {'url': '/'}), name='nocache_home'),
)
Clearly this won't work but does anyone know the trick which would enable this?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow