title: Django: resize image before upload
body: <p>I want to resize image(<strong>Pillow</strong>) before upload, I write code below but doesn't work!
  <strong>and get error:</strong></p>
  <blockquote>
  <p>AttributeError at /myapp/list/</p>
  <p>_committed</p>
  <p>Request Method:   POST</p>
  <p>Request URL:  <a href="http://127.0.0.1:8000/myapp/list/" rel="nofollow noreferrer">http://127.0.0.1:8000/myapp/list/</a>
  Django Version:   1.8 Exception Type:     AttributeError Exception Value:</p>
  <p>_committed</p>
  <p>Exception Location:</p>
  <p>/usr/local/lib/python3.4/dist-packages/Pillow-2.8.1-py3.4-linux-x86_64.egg/PIL/Image.py</p>
  <p>In <strong>getattr</strong>, line 622 Python Executable:   /usr/bin/python3.4 Python
  Version:  3.4.0</p>
  </blockquote>
  <p><strong>views.py</strong></p>
  <pre><code>def list(request):
  # Handle file upload
  if request.method == 'POST':
      form = DocumentForm(request.POST, request.FILES)
      if form.is_valid():
          imga = request.FILES['docfile']
          size = (600, 400)
          im = Image.open(imga)
          imga = im.resize(size)
          request.FILES['docfile'] = imga
          newdoc = Document(docfile = request.FILES['docfile'], namefile=request.POST['namefile'])
          newdoc.save()
  
          # Redirect to the document list after POST
          return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
  else:
      form = DocumentForm() # A empty, unbound form
  
  # Load documents for the list page
  documents = Document.objects.all()
  
  # Render list page with the documents and the form
  return render_to_response(
      'myapp/list.html',
      {'documents': documents, 'form': form},
      context_instance=RequestContext(request)
  )
  </code></pre>