ModuleNotFoundError: No module named 'xxxdjango'

Viewed 1161

I've been looking thoroughly before asking this question but couldn't find the answer on Stack Overflow. ModuleNotFoundError: No module named 'firstappdjango' has a similar error but does not solve my problem.

I've launched default app without problems and got Django screen etc. I am following a tutorial now and I started simple app with some HTML response. I get error called ModuleNotFoundError: No module named 'adamprojectdjango' when I want to run server.

What I've checked/some info

  • my app is called adamproject

  • app installed in settings.py

    INSTALLED_APPS = [
        'adamproject'
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
    ]
    
  • directories look as below

       /home/none/eclipse-workspace/test5
        ├── adamproject
        │   └── migrations
        └── test5
        └── __pycache__
    
  • app config file:

    from django.apps import AppConfig
    class MysiteConfig(AppConfig):
        name = 'adamproject'
    
1 Answers

Consider the following:

my_string = 'adamproject' 'django.contrib.admin'
print(my_string)
# prints:
# adamprojectdjango.contrib.admin

You have a missing comma after 'adamproject'. So it is being concatenated to what you intended to be the subsequent list entry. This results in an attempt to load an app from the module adamprojectdjango which does not exist.

INSTALLED_APPS = [
    'adamproject'
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

print(INSTALLED_APPS)
# prints:
# ['adamprojectdjango.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles']

Instead, your list of INSTALLED_APPS should be declared like this:

INSTALLED_APPS = [
    'adamproject',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
Related