Ok, so I'm sure that I violated DRY and probably a few other good
programming principles, but here's what I did that worked and doesn't
alter the source. It's a hack, but I'm still learning.
I created a new monkey_patches.py file and copied the function from
the core file and altered it. Now I just call @really_never_cache
instead.
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.3, 2.4
fallback.
from django.utils.decorators import decorator_from_middleware
from django.utils.cache import patch_cache_control,
add_never_cache_headers
from django.middleware.cache import CacheMiddleware
def really_never_cache(view_func):
"""
Replacement Decorator for never_cache that adds a few more headers
to a response so that it will never be cached.
"""
def _wrapped_view_func(request, *args, **kwargs):
response = view_func(request, *args, **kwargs)
add_never_cache_headers(response)
response['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
response['Pragma'] = 'no-cache'
response['Cache-Control'] = 'no-cache, no-store, max-age=0,
must-revalidate'
return response
return wraps(view_func)(_wrapped_view_func)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---