title: Where to put Django startup code?
body: <p>I'd like to have these lines of code executed on server startup (both development and production):</p>
  
  <pre><code>from django.core import management
  management.call_command('syncdb', interactive=False)
  </code></pre>
  
  <p>Putting it in <code>settings.py</code> doesn't work, as it requires the settings to be loaded already.</p>
  
  <p>Putting them in a view and accessing that view externally doesn't work either, as there are some middlewares that use the database and those will fail and not let me access the view.</p>
  
  <p>Putting them in a middleware would work, but that would get called each time my app is accessed. An possible solution might be to create a middleware that does all the job and then removes itself from <code>MIDDLEWARE_CLASSES</code> so it's not called anymore. Can I do that without too much monkey-patching?</p>