Django ) Postgresql model ERROR
Question: In models.py in my app of django, I have a model below :

    
    
    from django.db import models
    from django.contrib.postgres.fields import *
    
    class lkmModel(models.Model):
    
        #Profile Image
        profileUrls = ArrayField(base_field=models.TextField,size=5)
        #profileUrls = models.TextField()
        """profileUrl2 = models.TextField()
        profileUrl3 = models.TextField()
        profileUrl4 = models.TextField()
        profileUrl5 = models.TextField()"""
        #Profile Basic
        name = models.CharField(max_length=20)
        status = models.CharField(max_length=20)
        age = models.IntegerField()
        residence = models.CharField(max_length=20)
        bloodType = models.CharField(max_length=20)
        religion = models.CharField(max_length=20)
    
        #KEY_WORD
        personaltiy = models.TextField()
        appearance = models.TextField()
        hobby = models.TextField()
        ability = models.TextField()
        idealType = models.TextField()
        career = models.TextField()
        best = models.TextField()
        badges = ArrayField(base_field=models.CharField(max_length=10))
        manual = models.TextField()
    
        def __str__(self):
            return  self.name
    

I'm trying to create an instance of lkmModel in models.py at lkm.py
Correspondent codes of lkm.py are below :

    
    
    from myApp.models import lkmModel
    
    def createModel(self,pictures,basics,keywords,badges,manual):
        lkmModelOne = lkmModel(profileUrls = pictures, name = basics[0] , status = basics[1] ,
                          bloodType = basics[2] , age = basics[3] , religion = basics[4] , residence = basics[5],
                          personality= keywords[0], appearance = keywords[1] , hobby = keywords[2] , ability = keywords[3],
                          idealType = keywords[4], career = keywords[5] , best = keywords[6], badges = badges , manual = manual)
        lkmModelOne.save()
    

When lkm.py is executed , I got an error below:

    
    
      Traceback (most recent call last):
      File "/Users/kyungmoon/projectDicrectory/project/myApp/lkm.py", line 8, in <module>
        from myApp.models import lkmModel
      File "/Users/kyungmoon/projectDicrectory/project/myApp/models.py", line 2, in <module>
        from django.contrib.postgres.fields import *
      File "/Users/kyungmoon/venv/myvenv/lib/python3.4/site-packages/django/contrib/postgres/fields/__init__.py", line 1, in <module>
        from .array import *  # NOQA
      File "/Users/kyungmoon/venv/myvenv/lib/python3.4/site-packages/django/contrib/postgres/fields/array.py", line 207, in <module>
        class ArrayLenTransform(Transform):
      File "/Users/kyungmoon/venv/myvenv/lib/python3.4/site-packages/django/contrib/postgres/fields/array.py", line 209, in ArrayLenTransform
        output_field = IntegerField()
      File "/Users/kyungmoon/venv/myvenv/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 166, in __init__
        self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
      File "/Users/kyungmoon/venv/myvenv/lib/python3.4/site-packages/django/conf/__init__.py", line 55, in __getattr__
        self._setup(name)
      File "/Users/kyungmoon/venv/myvenv/lib/python3.4/site-packages/django/conf/__init__.py", line 41, in _setup
        % (desc, ENVIRONMENT_VARIABLE))
    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.
    

As you see, the error is from postgresql and arrayField of postgresql. But in
models.py , I created a lkmModel in a right way, isn't it?

Why does this happen?

I did install postgresql in my local machine and created a db called lkmDB and
a table for this. My DATABASES setting in settings.py in project is below :

    
    
    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'lkmDB',
        'USER': 'kyungmoon',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
    

}


Answer: None of this has anything whatsoever to do with the code you've posted.

You are presumably doing this in a plain Python shell; you should start up the
Django shell with `python manage.py shell` instead.

