Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.9 Tutorial Part 2: No module named 'polls.apps' when running python manage.py makemigrations polls

Tags:

python

django

There are numerous similar questions here on SO, but they all seem to be for older versions, or are related to a typo.

In part 2 of the Django 1.9 tutorial, I am stuck at the initial migration for the polls app:

python manage.py makemigrations polls

When running this, I get the error: `ImportError: No module named 'polls.apps'

I am using Python 3.5.1 and Django 1.9.4

excerpt from mysite/settings.py

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

Folder structure:

.
├── db.sqlite3
├── manage.py
├── mysite
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── __pycache__
│   ├── settings.py
│   ├── settings.pyc
│   ├── urls.py
│   └── wsgi.py
└── polls
    ├── __init__.py
    ├── __pycache__
    ├── admin.py
    ├── models.py
    ├── tests.py
    ├── urls.py
    └── views.py

4 directories, 21 files
like image 255
waffl Avatar asked Dec 14 '22 07:12

waffl


2 Answers

You are missing the apps.py file (and the polls.migrations package also) which should have been generated on this step: Creating the Polls app. Please review to ensure you've completed that step correctly.

like image 61
alecxe Avatar answered May 13 '23 13:05

alecxe


What about if you replace

INSTALLED_APPS = [
    'polls.apps.PollsConfig',
    ...
]

by just

INSTALLED_APPS = [
    'polls',
    ...
]
like image 21
rfrp Avatar answered May 13 '23 13:05

rfrp