title: Access django sqlite db from external script
body: <p>I want to prepopulate my db using an external script. The script is the following</p>
  
  <pre><code># -*- coding:utf-8-*-
  import os, sys
  from random import choice
  PROJECT_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__),'..','..'))
  
  sys.path.append(PROJECT_DIR)
  os.environ['DJANGO_SETTINGS_MODULE']='geoedu.settings'
  
  from school.models import School    
  from student.models import Student
  
  if __name__=='__main__':
      student = Student(first_name=choice(first_names_males), last_name=choice(last_names_males),
                    father_name=choice(first_names_males), mother_name=choice(first_names_females),
                    mobile=choice(mobiles), telephone=choice(telephones))
      student.save()
  </code></pre>
  
  <p>where the arguments in choice are lists with names and telephones. When i run it though i get the following error</p>
  
  <pre><code>django.db.utils.DatabaseError: no such table: student_student
  </code></pre>
  
  <p>The directory tree</p>
  
  <pre><code>geoedu
  ├── geoedu
  │   ├── __init__.py
  │   ├── __init__.pyc
  │   ├── settings.py
  │   ├── settings.pyc
  │   ├── urls.py
  │   ├── urls.pyc
  │   ├── wsgi.py
  │   └── wsgi.pyc
  ├── geoedu.db
  ├── geoedu.sublime-project
  ├── geoedu.sublime-workspace
  ├── manage.py
  ├── school
  │   ├── admin.py
  │   ├── admin.pyc
  │   ├── __init__.py
  │   ├── __init__.pyc
  │   ├── models.py
  │   ├── models.pyc
  │   ├── tests.py
  │   └── views.py
  ├── scripts
  │   └── populate.py
  └── student
      ├── admin.py
      ├── admin.pyc
      ├── __init__.py
      ├── __init__.pyc
      ├── models.py
      ├── models.pyc
      ├── tests.py
      └── views.py
  </code></pre>
  
  <p>What it does is it creates a new geoedu.db inside the script folder and uses that(which is empty and has no student_student table ofcourse)</p>
  
  <p>Why is that happening?The PROJECT_DIR is the correct one(printed it out) and is the root of the tree that is the geodedu on the top of all. </p>
  
  <p>EDIT: new geoedu.db gets created when creating new student. If I comment out those lines geoedu.db doesn't get created. </p>