Import Error Running script to populate database using models

21 views
Skip to first unread message

miguel vfx

unread,
Sep 20, 2016, 6:50:12 AM9/20/16
to Django users
Good day,

I'm getting import errors when I try to run a script to populate a database using models. I'm new to django so it means I haven't done anything special than follow djangobook and other beginner tutorials.

The script I would like to run is in the same folder as the models.py. I figured I was going to use the same import headings as admin.py but I'm getting the following error:

from .models import currentRecord

SystemError: Parent module '' not loaded, cannot perform relative import

Further searching for solutions, I stumbled upon adding this lines:

from models import currentRecord

    sys.path.append('E:/misite/')
    os.environ['DJANGO_SETTINGS_MODULE']='project.settings'
    django.setup()
 
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
 
I would really appreciate any pointers.

Thank you
Reply all
Reply to author
Forward
0 new messages