Compare commits

...

2 Commits

Author SHA1 Message Date
Flatlogic Bot
c9235c6961 github dibug 2026-02-14 12:37:03 +00:00
Flatlogic Bot
79550235ff chore: add heroku compatibility (whitenoise, dj-database-url) 2026-02-14 09:58:46 +00:00
4 changed files with 27 additions and 2 deletions

View File

@ -1,6 +1,10 @@
libgobject-2.0-0
libpango-1.0-0
libpangocairo-1.0-0
libcairo2
libharfbuzz0b
libfontconfig1
libpangoft2-1.0-0
libgdk-pixbuf2.0-0
libffi-dev
shared-mime-info

View File

@ -1 +1,2 @@
web: gunicorn config.wsgi --log-file -
release: python manage.py migrate
web: gunicorn config.wsgi --log-file -

View File

@ -1,5 +1,6 @@
import os
import sys
import dj_database_url
from pathlib import Path
from django.utils.translation import gettext_lazy as _
@ -13,7 +14,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'django-insecure-change-me-locally')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', 'True') == 'True'
DEBUG = os.environ.get('DEVELOPMENT', 'False') == 'True'
ALLOWED_HOSTS = ['*']
@ -21,6 +22,7 @@ CSRF_TRUSTED_ORIGINS = [
'https://*.flatlogic.app',
'https://*.flatlogic.run',
'https://*.flatlogic.com',
'https://*.herokuapp.com',
'http://localhost:8000',
'http://127.0.0.1:8000',
]
@ -41,6 +43,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
@ -87,6 +90,11 @@ DATABASES = {
}
}
# Use DATABASE_URL if it is set (standard for Heroku)
db_from_env = dj_database_url.config(conn_max_age=600)
if db_from_env:
DATABASES['default'].update(db_from_env)
# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
@ -139,6 +147,16 @@ STATICFILES_DIRS = [
BASE_DIR / "assets",
]
# Whitenoise storage for compressed and cached static files
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}
# Conditionally add node_modules if it exists (prevents W004 warning)
if (BASE_DIR / 'node_modules').exists():
STATICFILES_DIRS.append(BASE_DIR / 'node_modules')

View File

@ -5,3 +5,5 @@ gunicorn==21.2.0
requests
openpyxl
WeasyPrint
dj-database-url
whitenoise