Created
February 18, 2016 10:29
-
-
Save nottrobin/689048cb1baedc84d440 to your computer and use it in GitHub Desktop.
How to add headers in your custom TemplateView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OurTemplateView(TemplateView): | |
| def render_to_response(self, context, **response_kwargs): | |
| # Get response from parent TemplateView class | |
| response = super(CmsTemplateFinder, self).render_to_response( | |
| context, **response_kwargs | |
| ) | |
| # Add Cache-Control and Expires headers | |
| patch_response_headers(response, cache_timeout=300) | |
| # Return response | |
| return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment