importing models issue

from polls.models import Question

django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

1 Like

Welcome @Ansarinizam123 !

We’re going to need more details here about this issue.

This looks like you might be working on the official Django tutorial. If so, what page and paragraph are you on?

What is the command you are issuing that is generating this error?

We’ll probably need to ask more questions, but we won’t know what’s needed until you answer these.

Ya this is oficiall tutorial at playing with API part2

Actually i am importing classes in polls app from models in python shell

here is details

from polls.models import Choice, Question
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\Nizam\Desktop\port folio\mysite\polls\models.py”, line 7, in
class Question(models.Model):
File “C:\Users\Nizam\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py”, line 129, in new
app_config = apps.get_containing_app_config(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Nizam\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\apps\registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
File “C:\Users\Nizam\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\apps\registry.py”, line 137, in check_apps_ready
settings.INSTALLED_APPS
File “C:\Users\Nizam\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\conf_init .py”, line 89, in getattr
self.setup(name)
File "C:\Users\Nizam\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\conf
init
.py", line 69, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

What command are you using to start the shell?

simply writing “python”

That’s not what the tutorial tells you to do to start the Django shell at Playing with the API

thanks Ken issue solved