Django and WhiteNoise on Coolify

Just a little note to remind myself and anyone playing around with Django on Coolify: the default Nixpacks for Django will run migrations but not collectstatic. So if you have problems with your images or CSS not appearing, the quick solution is:

  1. Install whitenoise
  2. Set STATIC_ROOT = BASE_DIR / "staticfiles" in your settings.py file
  3. Add a nixpacks.toml file in your Django base directory that overrides the default run command and adds a collectstatic step
[start]
  cmd = "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn app.wsgi"

Then redeploy and you should have your static files display again.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *