title: File Upload gives Bad Request in Django using modelform
body: <p>I am trying to upload a file using a model form but form.save() is giving me bad request.
  This is my model:</p>
  
  <pre><code>class cv(models.Model):
      name = models.CharField('Name', max_length=64, null=True)
      path_to_cv = models.FileField('CV', upload_to='/', null=True)
  </code></pre>
  
  <p>Here is the form:</p>
  
  <pre><code>class Step2(forms.ModelForm):
      class Meta:
      model = cv
  </code></pre>
  
  <p>Here is the view:</p>
  
  <pre><code>def phdStep2(request):
      if request.method == 'POST':
          form = PhdStep2(request.POST, request.FILES)
          if form.is_valid():
              form.save()
              return HttpResponseRedirect('/step/3/')
      else:
          form = PhdStep2()
      return render(request, 'step2.html', {'form': form})
  </code></pre>
  
  <p>Here is the template for form:</p>
  
  <pre><code>&lt;form action="/step/2" method="post" class="well form" role="form" enctype="multipart/form-data"&gt;
  {% csrf_token %}
  {% bootstrap_form form %}
  {% buttons %}
      &lt;button type="submit" class="btn btn-primary"&gt;
          Submit
      &lt;/button&gt;
  {% endbuttons %}
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the media_root in settings.py:</p>
  
  <pre><code>MEDIA_ROOT = '/home/supertux/PyCharm/myproject/admissions/media'
  MEDIA_URL = '/media/'
  </code></pre>
  
  <p>I have read like 10s of such threads and find that most times problem was enctype in form which i already incorporated. Now as i understand, this should upload the file since its a model form, but i always get a 400 Bad Request. I want to store the name and path to the file in database. What am i doing wrong?</p>