I am doing the Django introductory tutorial from here: https://docs.djangoproject.com/en/1.9/intro/tutorial05/
As described there, I opened the python shell and tried to import the project, like this:
from polls.models import Question
However, I get this error:
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 don't understand the error message very well. Where exactly should I define DJANGO_SETTINGS_MODULE
or call settings.configure()
?
If I try to open the django shell, I get the same message.
Run python manage.py shell
from the root of your project - it automatically sets the environment variable pointing to your project settings.
Or, open the Django shell via django-admin
setting the environment variable beforehand:
$ export DJANGO_SETTINGS_MODULE="myproj.settings"
$ django-admin shell # requires the DJANGO_SETTINGS_MODULE to be set
Also see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With