Errors when i use python manage.py runserver

Please help me, I’ve been sitting with this bug all day and trying to solve it. when running python manage.py runserver I get this:

Traceback (most recent call last):
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\commands\runserver.py", line 74, in execute
    super().execute(*args, **options)
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\commands\runserver.py", line 81, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
           ^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\__i
nit__.py", line 89, in __getattr__
    self._setup(name)
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\__i
nit__.py", line 76, in _setup
    self._wrapped = Settings(settings_module)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\__i
nit__.py", line 190, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2288.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py", line 126, in import_module   
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'djangoProject78'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\leon2\OneDrive\Рабочий стол\djangoProject\djangoProject78\manage.py", line 22, in <module>
    main()
  File "C:\Users\leon2\OneDrive\Рабочий стол\djangoProject\djangoProject78\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\man
agement\base.py", line 426, in run_from_argv
    connections.close_all()
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\co
nnection.py", line 84, in close_all
    for conn in self.all(initialized_only=True):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\co
nnection.py", line 76, in all
    return [
           ^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\co
nnection.py", line 73, in __iter__
    return iter(self.settings)
                ^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\fu
nctional.py", line 47, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\co
nnection.py", line 45, in settings
    self._settings = self.configure_settings(self._settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\db\utils
.py", line 148, in configure_settings
    databases = super().configure_settings(databases)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\co
nnection.py", line 50, in configure_settings
    settings = getattr(django_settings, self.settings_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\__i
nit__.py", line 89, in __getattr__
    self._setup(name)
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\__i
nit__.py", line 76, in _setup
    self._wrapped = Settings(settings_module)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leon2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\__i
nit__.py", line 190, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2288.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py", line 126, in import_module   
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'djangoProject78'

here is my project structure:

my settings.py:

"""
Django settings for djangoProject78 project.

Generated by 'django-admin startproject' using Django 5.0.1.

For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-@ha1*%l33cicd*sdh)0(t2s=-8d9dec#+5_dyrw2^%f+x506=h'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'man.apps.ManConfig',
    'app.apps.AppConfig'





]

PATH_TO_YOUR_STATIC_FOLDER='man/static/'
STATICFILES_DIRS = [
    BASE_DIR / "man/static",
    PATH_TO_YOUR_STATIC_FOLDER,
]



MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'djangoProject78.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'djangoProject78.wsgi.application'


# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'man/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

my manage.py:

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoProject78.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()

my apps:

from django.apps import AppConfig


class ManConfig(AppConfig):

    name = 'djangoProject78.man'
    label = 'man'

i hope someone can help me

It’s hard to tell from the image you posted what your directory structure is supposed to be.

See the thread at crash after installation of bootstrap3 for a discussion of what the general layout of your directories should be.

What is your base (or project) directory?

Do you have the same named directory inside it?

Do you have a different directory for your app?

i just dont know why error with import error and name of my project, i tried solve it by finding same names but nothing

Because it looks like your directory structure is wrong.

You need to start out my making sure you have the right directories in the right places, and that the appropriate files are in the right directories.

how can i do this? maybe i can reinstall django?

I really need to solve this problem, I have been working on this project for a very long time, if you try to help me I will be very grateful. What can i do?

Start by answering the three questions I asked in my first reply.

Then read the thread I linked to.

Then explain to me how your project is organized by directories and how it is organized matches up with the structure described in that other thread.

Also, please understand that we are all volunteers here, answering questions as time, energy and knowledge allows. A response to any individual post or request may take days to be answered.

Sorry for my haste, I really appreciate your work and the fact that you help other people for nothing. I looked at the thread you linked to and tried to make a similar structure to the one that was presented:

error did not disappear, even though I did not touch the bootstrap. Thanks again for your patience. I will be glad if you answer

You still haven’t described what your intent is for your directory structure here.

I’m going to assume for the moment that you are intending for djangoProject to be your “outer” directory.

That directory should have your manage.py and db.sqlite3 files, along with your djangoProject78 and man directories.

I’m then going to assume that you’re intending for your djangoProject78 directory to be the “inner” directory. It should have your settings.py, asgi.py and wsgi.py files as described in my other post. Your man app directory should not be in djangoProject78.

1 Like

Thank you very much, you really helped me a lot. I did everything exactly as you described and after that the project finally worked. You literally saved me, it means a lot to me. I wish you all the best, you are truly a good person. I’ll leave a screenshot just in case someone has the same problem, thanks again. Goodbye

hello I have the same issue
directory:
drwxr-xr-x 3 nt1506 nt1506 4096 Feb 22 17:10 …
-rw-r–r-- 1 nt1506 nt1506 0 Feb 22 21:59 ‘=2.2,’
drwxr-xr-x 2 nt1506 nt1506 4096 Mar 1 12:40 backup
-rw-r–r-- 1 nt1506 nt1506 3 Feb 24 14:09 base.py
-rw-rw-r-- 1 nt1506 nt1506 343 Jan 13 2015 bower.json
-rw-rw-r-- 1 nt1506 nt1506 31 Jan 13 2015 .bowerrc
drwxr-xr-x 5 nt1506 nt1506 4096 Mar 5 13:44 build
drwxr-xr-x 2 nt1506 nt1506 4096 Mar 5 13:44 dist
drwxrwxr-x 2 nt1506 nt1506 4096 Feb 28 15:02 docs
-rw-rw-r-- 1 nt1506 nt1506 7279 Feb 24 14:09 fabfile.py
-rwxrwxr-x 1 nt1506 nt1506 436 Mar 3 20:46 manage.py
drwxrwxr-x 8 nt1506 nt1506 4096 Mar 3 19:51 noc
drwxr-xr-x 2 nt1506 nt1506 4096 Mar 5 13:44 noc.egg-info
-rw-r–r-- 1 nt1506 nt1506 6 Feb 22 21:54 .python-version
-rwxrwxr-x 1 nt1506 nt1506 226 Jan 13 2015 rancid-import.sh
-rw-rw-r-- 1 nt1506 nt1506 535 Jan 13 2015 README.rst
-rw-rw-r-- 1 nt1506 nt1506 288 Feb 23 13:45 requirements.pip
-rw-rw-r-- 1 nt1506 nt1506 96 Jan 13 2015 run.bat
-rwxrwxr-x 1 nt1506 nt1506 35 Jan 26 2015 run.sh
-rw-rw-r-- 1 nt1506 nt1506 328 Feb 27 22:51 setup.py
drwxrwxr-x 4 nt1506 nt1506 4096 Feb 6 2015 .svn
-rw-rw-r-- 1 nt1506 nt1506 129 Jan 13 2015 trash-db.bat
drwxr-xr-x 5 nt1506 nt1506 4096 Feb 24 16:57 venv

noc dir:
ls -alt noc
total 48
drwxrwxr-x 10 nt1506 nt1506 4096 Mar 5 13:44 …
drwxrwxr-x 3 nt1506 nt1506 4096 Mar 3 20:47 settings
drwxrwxr-x 8 nt1506 nt1506 4096 Mar 3 19:51 .
-rw-rw-r-- 1 nt1506 nt1506 835 Mar 3 18:43 urls.py
drwxrwxr-x 2 nt1506 nt1506 4096 Mar 2 08:45 pycache
-rw-rw-r-- 1 nt1506 nt1506 1156 Feb 24 14:09 wsgi.py
-rw-rw-r-- 1 nt1506 nt1506 0 Feb 24 14:09 init.py
drwxrwxr-x 11 nt1506 nt1506 4096 Feb 23 18:06 apps
drwxrwxr-x 2 nt1506 nt1506 4096 Jan 13 2015 templates
drwxrwxr-x 23 nt1506 nt1506 4096 Jan 13 2015 static
-rw-rw-r-- 1 nt1506 nt1506 1063 Jan 13 2015 urls.pyc
-rw-rw-r-- 1 nt1506 nt1506 126 Jan 13 2015 init.pyc
drwxrwxr-x 2 nt1506 nt1506 4096 Jan 13 2015 var

noc/settings/

.
drwxrwxr-x 2 nt1506 nt1506 4096 Mar 3 20:40 pycache
-rw-rw-r-- 1 nt1506 nt1506 949 Mar 3 20:40 local.py
drwxrwxr-x 8 nt1506 nt1506 4096 Mar 3 19:51 …
-rw-rw-r-- 1 nt1506 nt1506 494 Feb 24 14:09 dev.py
-rw-rw-r-- 1 nt1506 nt1506 4616 Feb 24 14:09 basebackup.py
-rw-rw-r-- 1 nt1506 nt1506 4921 Feb 24 14:09 base.py
-rw-rw-r-- 1 nt1506 nt1506 0 Feb 24 14:09 init.py
-rw-rw-r-- 1 nt1506 nt1506 2990 Jan 13 2015 base.pyc
-rw-rw-r-- 1 nt1506 nt1506 135 Jan 13 2015 init.pyc
-rw-rw-r-- 1 nt1506 nt1506 896 Jan 13 2015 local.pyc
-rw-rw-r-- 1 nt1506 nt1506 642 Jan 13 2015 local.py.example

my project was old python now using python 3 where do i start ?

when i run python3 manage.py or add runserver etc i get

python manage.py runsever
[‘/home/nt1506/NOC-Central/noc-central/noc-central’, ‘/home/nt1506/.pyenv/versions/3.9.7/lib/python39.zip’, ‘/home/nt1506/.pyenv/versions/3.9.7/lib/python3.9’, ‘/home/nt1506/.pyenv/versions/3.9.7/lib/python3.9/lib-dynload’, ‘/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages’, ‘/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/noc-1.0-py3.9.egg’]
Traceback (most recent call last):
File “/home/nt1506/NOC-Central/noc-central/noc-central/manage.py”, line 13, in
from noc.apps.rancidmanager.models import InstallationParameter
File “/home/nt1506/NOC-Central/noc-central/noc-central/noc/apps/rancidmanager/models.py”, line 2, in
from noc.apps.platformprovisioningtool.models import InstallationParameter
File “/home/nt1506/NOC-Central/noc-central/noc-central/noc/apps/platformprovisioningtool/models.py”, line 24, in
class InstallationOutput(models.Model):
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/db/models/base.py”, line 129, in new
app_config = apps.get_containing_app_config(module)
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/apps/registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/apps/registry.py”, line 137, in check_apps_ready
settings.INSTALLED_APPS
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/conf/init.py”, line 102, in getattr
self._setup(name)
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/conf/init.py”, line 89, in _setup
self._wrapped = Settings(settings_module)
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/conf/init.py”, line 271, in init
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: DEFAULT_FILE_STORAGE/STORAGES are mutually exclusive.

please help i am stuck

Welcome @nivatony !

You have posted this on a topic that has been marked as solved.

This is a different issue with a different error. I suggest you open a new topic with this complete error message and the contents of your settings.py file, but do not include the directory listing unless asked.

Also Note: When posting code, templates, or error messages here, enclose the text between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.