Oryx attempts to build and run Django apps appropriately, but some configuration is not automated, so following are instructions for setting this yourself. If you'd like us to include these automatically please open an issue, thanks!
You may also want to review Heroku's django-heroku package for ideas.
-
Add App Service's default suffix to the list of allowed hosts in
settings.py
:// settings.py ALLOWED_HOSTS = [ '.azurewebsites.net' ]
-
Oryx runs
manage.py collectstatic
on your behalf unless you specify theDISABLE_COLLECTSTATIC
env var (see our [configuration doc](. But make sure you've set STATIC_ROOT insettings.py
:// settings.py STATIC_ROOT = './static/'
-
To host static files in your web app, add the whitenoise package to
requirements.txt
and the configuration for it tosettings.py
.# requirements.txt whitenoise==4.1.2
// settings.py MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
-
To apply database schema migrations following a build, create a post-build shell script and set its repo-relative path in the
POST_BUILD_SCRIPT_PATH
environment variable, e.g.POST_BUILD_SCRIPT_PATH=./scripts/post.sh
. The script should contain the following.#! /usr/bin/env sh python manage.py migrate