[Answer]-Apply a never_cache to a flatpage view

1👍

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')
)

Leave a comment