Skip to content
Latchkey

Django "ModuleNotFoundError: No module named settings" in CI

DJANGO_SETTINGS_MODULE names a dotted path Django cannot import. The variable is set, but the project root is not on sys.path, or the module path is wrong (for example a split settings package with no matching submodule).

What this error means

Any Django command fails while loading settings with "ModuleNotFoundError: No module named 'myproject.settings'" or "No module named 'myproject.settings.ci'".

Django
ModuleNotFoundError: No module named 'myproject.settings.ci'
The above exception was the direct cause of the following exception:
django.core.exceptions.ImproperlyConfigured: Could not import settings 'myproject.settings.ci'

Common causes

The project root is not on the import path

CI runs from a subdirectory, or the repo is checked out into a nested path, so myproject is not importable and the settings module cannot be found.

A dotted path that does not exist

You reference myproject.settings.ci but the settings package has no ci.py, or you kept a single settings.py and used a package-style path.

How to fix it

Run from the directory that holds the package

  1. Confirm manage.py and the project package sit at the checkout root.
  2. Set working-directory if your Django project lives in a subfolder.
  3. Verify the exact submodule named in DJANGO_SETTINGS_MODULE exists.
.github/workflows/ci.yml
defaults:
  run:
    working-directory: ./backend

Match the variable to a real module

A split settings package needs an importable submodule. Point the variable at a file that exists.

Terminal
# backend/myproject/settings/ci.py must exist
export DJANGO_SETTINGS_MODULE=myproject.settings.ci

How to prevent it

  • Keep manage.py and the project package at the checkout root or set working-directory.
  • Verify the settings submodule path exists before pushing.
  • Use a src/ layout consistently so import paths are predictable.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →