title: How to initialize django database when using django and south
body: <p>I try to write a script that will reset and reinitialize the database for a new django application. In order to detect any error I want to check the return code of each command.</p>
  
  <pre><code>#! /bin/env python
  import sys, os 
  
  def execute⌘:
      print(cmd)
      ret = os.system(cmd)
      if not ret:
          sys.exit("Last command failed")
  
  if __name__ == "__main__":
      if os.path.isfile('app.sqlite'):
          os.unlink('app.sqlite')
  
      execute('python manage.py syncdb --noinput --all') # &lt;&lt; this fails
      execute('python manage.py migrate --noinput --all')
  </code></pre>
  
  <p>My problem is that I wasn't able to find a way to safely re-initialize the database. Running <code>migrate</code> fails because it requires <code>syncdb</code> and <code>syncdb</code> fails because it requires <code>migrate</code>.</p>
  
  <p>Do not ask me to ignore the return codes from the commands, I want a solution that is able to properly deal with error codes.</p>