Skip to content

Instantly share code, notes, and snippets.

@AndrewIngram
Created October 17, 2012 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewIngram/3905739 to your computer and use it in GitHub Desktop.
Save AndrewIngram/3905739 to your computer and use it in GitHub Desktop.
MimeTemplateView
class MimeTemplateView(TemplateView):
@classonlymethod
def as_view(cls, **kwargs):
setattr(cls, 'mimetype', kwargs.pop('mimetype','text/html'))
return super(MimeTemplateView, cls).as_view(**kwargs)
def render_to_response(self, context, **kwargs):
kwargs['mimetype'] = self.mimetype
return super(MimeTemplateView, self).render_to_response(context, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment