title: Send a file through Django Class Based Views
body: <p>We use class based views for most of our project.  We have run into an issue when we try and create a CSV Mixin that will allow the user to export the information from pretty much any page as a CSV file.  Our particular problem deals with CSV files, but I believe my question is generic enough to relate to any file type.</p>
  
  <p>The problem we are having is that the response from the view is trying to go to the template (say like <code>from django.views.generic import TemplateView</code>).  We specify the template in the <code>urls.py</code> file.</p>
  
  <pre><code>url(r'^$', MyClassBasedView.as_view(template_name='my_template.html'))
  </code></pre>
  
  <p>How can you force the response to bypass the template and just return a standard <code>HttpResponse</code>?  I'm guessing you'll need to override a method but I'm not sure which one.</p>
  
  <p>Any suggestions?</p>
  
  <p>EDIT1:  It appears that I was unclear as to what we are trying to do.  I have rendered a page (via a class based view) and the user will see reports of information.  I need to put in a button "Export to CSV" for the user to press and it will export the information on their page and download a CSV on to their machine.</p>
  
  <p>It is not an option to rewrite our views as method based views.  We deal with almost all class based view types (DetailView, ListView, TemplateView, View, RedirectView, etc.)</p>