title: Django file uploads - Just can't work it out
body: <p>OK I give up - after 5 solid hours trying to get a django form to upload a file, I've checked out all the links in stackoverflow and googled and googled.  Why is it so hard, I just want it to work like the admin file upload?</p>
  
  <p>So I get that I need code like:</p>
  
  <pre><code>            if submitForm.is_valid():
                    handle_uploaded_file(request.FILES['attachment'])
                    obj = submitForm.save()
  </code></pre>
  
  <p>and I can see my file in request.FILES['attachment'] (yes I have enctype set) but what am I supposed to do in handle_uploaded_file?  The examples all have a fixed file name but obviously I want to upload the file to the directory I defined in the model, but I can't see where I can find that.  </p>
  
  <pre><code>def handle_uploaded_file(f):
    destination = open('fyi.xml', 'wb+')
    for chunk in f.chunks():
      destination.write(chunk)
    destination.close()
  </code></pre>
  
  <p>Bet I'm going to feel really stupid when someone points out the obvious!</p>