title: Django - distinguish development server (manage.py runserver) from the regular one (eg. Apache)
body: <p>I need a way to <strong>distinguish development server in Django (run eg. by <code>./manage.py runserver 0.0.0.0:8000</code>) from the one being run on Apache</strong>. In case of Apache I use WSGI daemon mode, but I would like to find some more reliable solution for detecting execution on Django's development server.</p>
  
  <p>What I currently use is similar to:</p>
  
  <pre class="lang-py prettyprint-override"><code>wsgi_wrapper = request.META.get('wsgi.file_wrapper')
  wsgi_wrapper_path = wsgi_wrapper.__module__ if wsgi_wrapper else None
  </code></pre>
  
  <p>which seemingly gives <code>wsgi_wrapper_path</code> storing:</p>
  
  <ul>
  <li>"<code>wsgiref.util</code>" string when run on Django's built-in development server,</li>
  <li><code>None</code> when run on Apache / WSGI in daemon mode,</li>
  </ul>
  
  <p>The problem here is I am not sure if I can rely on that check (eg. if the production/staging/development server or my localhost configuration changes). I was not able to find any documentation regarding that.</p>
  
  <p><strong>I need that check primarily because of one issue with Django's development server</strong>: it sets request's <code>CONTENT_TYPE</code> (<code>request.META['CONTENT_TYPE']</code>) to "<code>text/plain</code>" even if the HTTP request itself had no content type set (eg. it was a <code>GET</code> request).</p>
  
  <p>Any ideas regarding Django's development server detection (or solving issue with incorrect request content type on it) will be appreciated. Thanks.</p>
  
  <p>Ps. I am basically asking this question: <a href="https://stackoverflow.com/q/1291755/548696">How can I tell whether my Django application is running on development server or not?</a> for Django 1.4, trying to determine the solution that will be reliable enough in case configuration changes.</p>