title: Exception: You cannot access body after reading from request's data stream
body: <p><a href="https://docs.djangoproject.com/en/1.5/ref/request-response/#django.http.HttpRequest.POST">Since Django 1.5 raw post data is accessible via request.body.</a></p>
  
  <p>In my application I sometimes get data send via a form and sometimes raw data (json for example). 
  Is there any way to write a function like this that does not fail?</p>
  
  <pre><code>def get_post_var(request, name):
      result = request.POST.get(name)
      if result:
          return result
  
      post_body = dict(urlparse.parse_qsl(request.body))
      result = post_body.get(name)
      if result:
          return result
  
      return None
  </code></pre>