title: Django test - How to send a HTTP Post Multipart with JSON
body: <p>in my django tests, I want to send an HTTP Post Multipart which contains 2 parameters:</p>
  
  <ul>
  <li>a JSON string</li>
  <li>a file</li>
  </ul>
  
  <pre class="lang-python prettyprint-override"><code>def test_upload_request(self):
      temp_file = tempfile.NamedTemporaryFile(delete=False).name
      with open(temp_file) as f:
          file_form = {
              "file": f
          }
          my_json = json.dumps({
              "list": {
                  "name": "test name",
                  "description": "test description"
              }
          })
          response = self.client.post(reverse('api:upload'),
                                      my_json,
                                      content=file_form,
                                      content_type="application/json")
      os.remove(temp_file)
  
  
  def upload(request):    
      print request.FILES['file']
      print json.loads(request.body)
  </code></pre>
  
  <p>My code doesn't work. Any help ?
  If necessary, I can use an external python lib (I'm trying with <strong>requests</strong>)
  Thank you</p>