Skip to content
Latchkey

Django "SECURITY WARNING: DEBUG" / check --deploy failing in CI

A CI gate that runs manage.py check --deploy --fail-level WARNING treats DEBUG being True as a failure. In CI, DEBUG often stays True because the boolean env var was parsed wrong (any non-empty string is truthy) or was never set.

What this error means

The check step fails listing "?: (security.W018) You should not have DEBUG set to True in deployment." along with other W-series deployment warnings promoted to errors.

Django
System check identified some issues:
WARNINGS:
?: (security.W018) You should not have DEBUG set to True in deployment.
?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting.

Common causes

A truthy string kept DEBUG True

Settings do DEBUG = os.environ.get("DEBUG", "False"), so the value is the string "False", which is truthy. DEBUG is effectively always on.

DEBUG defaults to True with no CI override

The base settings default DEBUG to True and the CI settings never turn it off, so the deploy check flags it.

How to fix it

Parse the boolean correctly

Compare the string explicitly instead of relying on truthiness.

settings/base.py
import os
DEBUG = os.environ.get("DEBUG", "False").lower() in ("1", "true", "yes")

Force DEBUG False in CI settings

A dedicated CI settings module can hardcode a safe value so the deploy check passes.

settings/ci.py
# settings/ci.py
from .base import *  # noqa
DEBUG = False

How to prevent it

  • Parse boolean env vars explicitly; never rely on string truthiness.
  • Set DEBUG = False in the CI settings module.
  • Run manage.py check --deploy as a dedicated gate step.

Related guides

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