title: enable to initialize other python module before first request (Django + mod_wsgi + apache)
body: <p>I am pretty new to web applications and recently working on a simple demo system using Django + mod_wsgi.
  the project looks like this:</p>
  
  <pre><code>django/
      |- manage.py
      |- mysite/
      |    |- url.py
      |    |- setting.py
      |    |- wsgi.py
      |- myapp/
           |- views.py
           |- taggers.py
           |- ...
  </code></pre>
  
  <p>and here is the <em>myapp.conf</em> configuration</p>
  
  <pre><code>WSGIDaemonProcess init python-home=/usr/local/.../3.5.0 python-path=/usr/local/.../django
  WSGIProcessGroup init
  WSGIImportScript /usr/local/.../django/mysite/wsgi.py process-group=init application-group=%{GLOBAL}
  WSGIApplicationGroup %{GLOBAL}
  WSGIScriptAlias /myapp /usr/local/.../django/mysite/wsgi.py
  &lt;Directory /usr/local/.../django/mysite&gt;
  &lt;Files wsgi.py&gt;
  Require all granted
  &lt;/Files&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>what this demo do is quite simple. given an input, press a 'compute' button, calculate the result using a pre-loaded machine learning model, which is loaded at the beginning of <em>views.py</em>. Loading the machine learning model will get involved with other python modules such as <em>sklearn</em> along with some self-made modules located in the same directory such as <em>tagger.py</em>. When I test this demo using 'python3 manage.py runserver', everything goes just fine. Django first loads the machine learning model to RAM, which is quite time-consuming, and wait for the incoming requests and then calculates.</p>
  
  <p>But when I use mod_wsgi + apache, I notice that when I start apache, only <em>wsgi.py</em> is executed. The machine learning model is not loaded (which means views.py is not yet imported) until the first access of this demo system through a browser. Even though everything looks fine after the first request, I mean there is no need to load the machine learning model for every calculation, I still hope to automatically load the machine learning model right after apache startup.
  I've seen someone talking about faking the first request but I really desired to know if there is another solution such as modifying the <em>wsgi.py</em>.</p>
  
  <p>To sum up my questions.</p>
  
  <ol>
  <li><p>how should I modify the default <em>wsgi.py</em> to import views.py in order to preload the machine learning model (directly import views.py in wsgi.py will lead to errors saying something like 'apps not installed' )</p></li>
  <li><p>if I have no choice but faking a request, where and how should I write it.</p></li>
  </ol>
  
  <p>Many thanks.</p>