Django Tutorial 2: Error in "Try Playing with API"

Asked 2 years ago, Updated 2 years ago, 112 views

I'm a Python beginner.I am proceeding with Django's tutorial, but when I call pols in IDLE, I get the following error:

>>from polls.models import Question, Choice
  Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
   from polls.models import Question, Choice
  ModuleNotFoundError: No module named 'polls'

What we did was change INSTALLED_APPS in mysite/urls.py as follows:

INSTALLED_APPS=[
    'polls.apps.PollsConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

The command line (?) also did the following:

 python manage.py makemigrations polls
python manage.py sqlmigrate polls0001
python manage.py migrate

What is the cause of the error?

python django

2022-09-30 21:30

1 Answers

Maybe it's because the Django version is old. This error occurs if the Django version is older than 1.9. python manage.py --version can verify the Django version.

Note: ImportError: No module named'polls.apps.PollsConfig' --Django tickets#27139


2022-09-30 21:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.