Fix Django superuser creation failing with ImproperlyConfigured error #9554
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✍️ Description
Django superuser creation in healthchecks installation fails with
django.core.exceptions.ImproperlyConfigured: Requested setting AUTH_USER_MODEL, but settings are not configured.Root cause: Python executed directly without Django settings initialization.
Fix: Use
manage.py shellto properly load Django settings before executing superuser creation code.This aligns with the pattern used in
netbox-install.shand other Django-based scripts in the repository.🔗 Related PR / Issue
Link: #4927
✅ Prerequisites (X in brackets)
🛠️ Type of Change (X in brackets)
README,AppName.md,CONTRIBUTING.md, or other docs.Original prompt
This section details on the original issue you should resolve
<issue_title>Healthchecks: django.core.exceptions.ImproperlyConfigured on creation of superuser</issue_title>
<issue_description>### ✅ Have you read and understood the above guidelines?
yes
🔎 Did you run the script with verbose mode enabled?
Yes, verbose mode was enabled and the output is included below
📜 What is the name of the script you are using?
Healthchecks
📂 What was the exact command used to execute the script?
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/healthchecks.sh)"
⚙️ What settings are you using?
🖥️ Which Linux distribution are you using?
Debian 13
📈 Which Proxmox version are you on?
pve-manager/8.4.1/2a5fa54a8503f96d (running kernel: 6.8.12-10-pve)
📝 Provide a clear and concise description of the issue.
Creation of superuser for healthchecks fails on fresh install
🔄 Steps to reproduce the issue.
Fresh install using bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/healthchecks.sh)"
❌ Paste the full error output (if available).
fixing permissions on existing directory /var/lib/postgresql/16/main ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Berlin
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Processing triggers for man-db (2.13.1-1) ...
Processing triggers for libc-bin (2.41-12) ...
✔️ Setup PostgreSQL 16
⏳ Setting up PostgreSQL DatabaseCREATE ROLE
CREATE DATABASE
ALTER ROLE
ALTER ROLE
ALTER ROLE
✔️ Set up PostgreSQL Database
✔️ Set up Keys
✔️ Deployed: healthchecks (3.13)
⏳ Installing Healthchecks (venv)Requirement already satisfied: pip in ./venv/lib/python3.13/site-packages (25.1.1)
Collecting pip
Downloading pip-25.3-py3-none-any.whl.metadata (4.7 kB)
Collecting wheel
Downloading wheel-0.45.1-py3-none-any.whl.metadata (2.3 kB)
Downloading pip-25.3-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 6.4 MB/s eta 0:00:00
Downloading wheel-0.45.1-py3-none-any.whl (72 kB)
Installing collected packages: wheel, pip
Attempting uninstall: pip
Found existing installation: pip 25.1.1
Uninstalling pip-25.1.1:
Successfully uninstalled pip-25.1.1
Successfully installed pip-25.3 wheel-0.45.1
Collecting gunicorn
Downloading gunicorn-23.0.0-py3-none-any.whl.metadata (4.4 kB)
Collecting aiosmtpd==1.4.6 (from -r requirements.txt (line 1))
Downloading aiosmtpd-1.4.6-py3-none-any.whl.metadata (6.6 kB)
Collecting cronsim==2.7 (from -r requirements.txt (line 2))
Downloading cronsim-2.7-py3-none-any.whl.metadata (6.9 kB)
Collecting Django==5.2.8 (from -r requirements.txt (line 3))
Downloading django-5.2.8-py3-none-any.whl.metadata (4.1 kB)
Collecting django-compressor==4.6 (from -r requirements.txt (line 4))
Downloading django_compressor-4.6.0-py3-none-any.whl.metadata (5.2 kB)
Collecting django-stubs-ext==5.2.7 (from -r requirements.txt (line 5))
Downloading django_stubs_ext-5.2.7-py3-none-any.whl.metadata (3.6 kB)
Collecting fido2==2.0.0 (from -r requirements.txt (line 6))
Downloading fido2-2.0.0-py3-none-any.whl.metadata (7.1 kB)
Collecting oncalendar==1.1 (from -r requirements.txt (line 7))
Downloading oncalendar-1.1.tar.gz (8.7 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting psycopg==3.2.13 (from -r requirements.txt (line 8))
Downloading psycopg-3.2.13-py3-none-any.whl.metadata (4.5 kB)
Collecting pycurl==7.45.7 (from -r requirements.txt (line 9))
Downloading pycurl-7.45.7-cp313-cp313-manylinux_2_28_x86_64.whl.metadata (4.5 kB)
Collecting pydantic==2.12.5 (from -r requirements.txt (line 10))
Downloading pydantic-2.12.5-py3-none-any.whl.metadata (90 kB)
Collecting PyJWT==2.10.1 (from PyJWT[crypto]==2.10.1->-r requirements.txt (line 11))
Downloading PyJWT-2.10.1-py3-none-any.whl.metadata (4.0 kB)
Collecting pyotp==2.9.0 (from -r requirements.txt (line 12))
Downloading pyotp-2.9.0-py3-none-any.whl.metadata (9.8 kB)
Collecting segno==1.6.6 (from ...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.