title: django jquery POST development server showing 500 status
body: <p>I'm trying to get multiple CSV file uploading to django based on <code>sigurdga / django-jquery-file-upload</code></p>
  
  <p>Being very new to javascript and jquery I'm trying to keep the changes to the example code as small as possible.</p>
  
  <p>I successfully changed it to upload general files instead of image files and got it uploading batches of CSV's.</p>
  
  <p>Right now I have a simple but fundamental problem with debugging.</p>
  
  <p>Something I have introduced is causing the Django development server to fail during the POST and return a 500 status - i can see that on the console output from the server. </p>
  
  <pre><code>[27/Jan/2014 12:29:31] "POST /banking/new/acount1234/ HTTP/1.1" 500 15103
  </code></pre>
  
  <p>I have debug print statements in various django functions including the relevant <code>view.form_valid</code>, <code>view.form_invalid</code> <code>model.save</code></p>
  
  <p>I've also added a custom <code>handler500</code> to see if I can catch something there.</p>
  
  <p>My problem is that the server is throwing a 500 but I can't work out where to put in some debugging.</p>
  
  <p>So my question is - is there somewhere in Django that I can intercept the URL processing to see why it's throwing a <code>500</code>?</p>
  
  <p>The documentation says that with DEBUG=True it shouldn't happen - but I know it does happen because if my <code>PgSQL</code> server is stopped it throws 500's on the <code>GET's</code></p>
  
  <p>I can't see a django debug page as the <code>js</code> page doesn't give me any status, and I'm not familiar enough to customise it.</p>
  
  <p>I'd have expected the control flow to end up in my <code>form_invalid</code> but it doesn't.</p>
  
  <p>I should add that based on the example I am using the generic <code>CBV</code> <code>CreateView</code> so maybe that is generating the <code>500</code> and perhaps I should crib the source code for that and create my own view code based on it that I can then instrument with <code>print's</code></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As I'm using the generic <code>CBVs</code>, there's a lot of stuff hidden behind the scenes.</p>
  
  <p>The only way I found to debug it was to actually copy the django source for CreateView and various super-classes to my own source file temporarily and put pdb breakpoints in.</p>
  
  <p>In summary I'd assumed I could use the off the shelf package to upload a file and add the additional fields for my model by overriding <code>form_valid</code> in the view or <code>save</code> in the <code>Model</code>.</p>
  
  <p>However <code>CreateView</code> checks that the object data is valid BEFORE I got access to it so it threw an exception for any fields that were <code>blank=False</code> or <code>null-False</code>.</p>
  
  <p>I changed my model to allow <code>Null</code> and <code>Blank</code> on all but the file and it allowed it through so that I could populate them in <code>form_valid</code>.</p>
  
  <p>Subsequently it threw another <code>500</code> because of an exception in my <code>CSV</code> processing with a non-ascii character in an upload file.</p>
  
  <p>There must be an easier way to debug stuff where client side scripting and <code>JSON</code> hide the simple server page response</p>