ModuleNotFoundError: No module named 'polls.app'

Hi. I have just started following the django documentation to writing your first django app and am currently stuck at the part where I’m supposed to be executing a makemigrations command right after I have added a reference to the configuration class in the INSTALLED_APPS setting.

Upon executing the command in the terminal, I received this error

PS C:\Users\Hasyeef\Desktop\project_env\mysite> py manage.py makemigrations polls
Traceback (most recent call last):
File “manage.py”, line 22, in
main()
File “manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “C:\Users\Hasyeef\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management_init_.py”, line 401, in execute_from_command_line
utility.execute()
File “C:\Users\Hasyeef\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management_init_.py”, line 377, in execute
django.setup()
File “C:\Users\Hasyeef\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django_init_.py”, line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File “C:\Users\Hasyeef\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\registry.py”, line 91, in populate
app_config = AppConfig.create(entry)
File “C:\Users\Hasyeef\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\config.py”, line 116, in create
mod = import_module(mod_path)
File “C:\Users\Hasyeef\AppData\Local\Programs\Python\Python38-32\lib\importlib_init_.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘polls.app’

My directory listings are as follows
mysite
mysite
mysite_pycache_
mysite_init_.py
mysite\asgi.py
mysite\settings.py
mysite\urls.py
mysite\wsgi.py
polls
polls_pycache_
polls\migrations
polls\migrations_init_.py
polls_init_.py
polls\admin.py
polls\apps.py
polls\models.py
polls\tests.py
polls\urls.py
polls\views.py
db.sqlite3
manage.py

This is my settings.py file. I have added the reference "polls.app.PollsConfig "

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

This is my apps.py file

from django.apps import AppConfig


class PollsConfig(AppConfig):
    name = 'polls' 

This is my models.py file

from django.db import models

# Create your models here.
class Question(models.Model):
  question_text = models.CharField(max_length=200)
  pub_date = models.DateTimeField('date published')

class Choice(models.Model):
  question = models.ForeignKey(Question, on_delete=models.CASCADE)
  choice_text = models.CharField(max_length=200)
  votes = models.IntegerField(default=0)

I suspect it may be due to the placement of my file directories but at this point, I’ve hit a brick wall and am not able to proceed along with the tutorial. Any advise?

It should be polls.apps.PollsConfig

You are missing the s at the end of “apps”

The dotted path in your INSTALLED_APPS setting needs to correctly point to your django app package, or the app config class inside your python package. You have a package named “polls” which contains a module called “apps” which has a class in it called “PollsConfig”

1 Like

Thank you so much! It works now. Can’t believe its over a missing letter :upside_down_face: