Environment variables

Freeturn uses django-environ to configure the application over environment variables and dotenv files. All the environment variables can be found in .env_template, here they are:

# recaptcha config for the forms
# sentry project id
# email url, see django-environ docs for more info
# oauth2 social auth config for google login
# aws access keys
# static and media storage aws s3 bucket name
# aws storage account id and user for s3 policy config, see
# redis url using django-environ notation
# google analytics id
# django debug mode, dont' set in prod
# django debug toolbar, see
# secret key for your project, see
# use redis to cache templates
# set in prod while using https as transport and heroku
# whitenoise storage compresses the media assets, recommended in prod
# path to set wkhtml binary, usually /usr/bin/wkhtmltopdf, for heroku buildback /app/bin/wkhtmltopdf
# use which wkhtmltopdf in the container to make sure it's there
# monitoring with scout apm,

Django environ built-in env

Additionally django environ offers (see docs) - DATABASE_URL for configuring the database, defaults to ./db.sqlite3 - REDIS_URL for configuring redis / cache urls (caches default to locmemcache) - EMAIL_URL for configuring email (defaults to consolemail)

Most of the activation different services and features in freeturn, default values are not suitable for production. Let's dig into it.


DATABASE_URL = 'sqlite:///<PROJECT_DIR>/db.sqlite3'

The default config uses locally stored sqlite database, which is particularly comfortable for local development, because of it's speed and quick setup. Besides that docker container and heroku dynos don't have persistent storages out of box, which makes them easily disposable and reproducable.

Long story short, this is not convenient for production use. Heroku dynos offer free postgres add-ons, which inject the database URL over the env variable DATABASE_URL, which makes it plug and play ready. Of course you are free to use any DBMS of your choice, consult django-environ docs for correct building of database URLs.


For same reason as the filesystem based databases are not suitable for production, the local filesystem storage won't work for heroku. This makes storing the uploads aka media files over heroku quite a peculiar task. Heroku recommends using AWS S3 for that, here is how it can be done.

AWS credentials


AWS credentials are the main key pair for you to access your AWS services. Freeturn utilizes django-storages for accessing the s3 storage and configuring it. Find more information on s3 in particular here.

S3 bucket


s3 bucket is an analog of a hard drive in terms of AWS cloud storage. s3 as such mimics the popular filesystems, with multiple differences though. Freeturn needs to know which bucket in your AWS account to use.

S3 bucket policy


Freeturn depends on wagtail-storages for managing the sensitive uploads securely, which requires some addional configuration steps. You can either copypast the wagtail-storages's or manually create the s3 bucket policy for your storage, that doesn't require AWS_STORAGE_ACCOUNT_ID nor AWS_STORAGE_USER to be configured. What you need those settings for, is that if you want to install the policy from template, which you can find in s3_policy.json.template. This is pretty much the recommended policy from wagtail-storages, where the user name and account id are injected as context. See the corresponding AWS docs to know how you can find out your account id and username.



Wagtail exposes the the forms to the wild internet, which means without any DoS protection. Freeturn uses django-recaptcha2 for enabling the google's recaptcha and make the submission process easy and comfortable for the visitors. In order to enable the recaptcha support, you would need the recaptcha public and private keys. See the recaptcha docs to know where you get the keys.


EMAIL_URL = 'consolemail://'

Freeturn would notify about different event over the email, in order to configure it, email url must be set. Consult django-environ docs to learn how those URLs are built and also make sure you to take at least a brief look at django email backends docs to find out the difference.

Google oauth2


In order to activate the gmail integration, freeturn uses wonderful python-social-auth and it's google oauth2 integration. Consulte the official docs to find the access keys.


python-social-auth backend will be only used if the keys are not empty

Setting up mail checker

Once freeturn's google email integration is configured, you'd need to set up the checker 'cron'. This utility checks if there are any emails in your inbox tagged CRM, parses their content and created the project entry for them. Find more info here.

The checker itself is called over the CLI invoke command inv mail. Put it in the crontab or if you use heroku, you could use heroku scheduler.


Heroku scheduler adds up to your usage metrics



Sentry is an outstanding bug monitoring tool, which allows you to see the exhaustive information about the incidents happening in your application. Sentry has both open source and free on premise version and cloud version, which is free for developers and small businesses. While you don't necessary need those for the production use, you could find it useful to find out the additional info for bugfixing. Follow the sign up wizard and you will be offered to add a project, which then will reveal your DSN - resource identification you'd put in the freeturn configuration.


Sentry environments will be configured automatically for review apps if ENVIRONMENT is not set, using HEROKU_APP_NAME env.

Frontend caching


While caching is more necessary for highly loaded sites, enabling caching in the admin can significantly speed up the admin interface on basic computing power. Set this variable to True to enable redis cache.


In order to speed up the static serving, freeturn uses django-whitenoise for compressing, preprocessing and minifying the static files. Set this variable to true to enable this feature.

Google analytics


Google analytics is a monstrous analytics tool to analyze your site performance and user behavior. Consult this docs to find out where you get this tracking id.

Scout APM


Freeturn offers scout apm integration, which allows you see all the performance insights. You can enable the integration with setting this variable to True and configure it using the environment variables from the official django integration.

Debug toolbar


Enables django debug toolbar. Django debug toolbar is a an extremely useful tool for finding the templates used, SQL queries made and much more, which you would probably need for development.


WKHTML is a tool for rendering html pages to pdf documents. Freeturn uses it for creating pdf documents such as cvs and invoices. In order to make it work wkhtml within your container must be installed and understood by django-wkhtmltopdf. Heroku luckily several buildpacks for it, wkhtmltopdf-buildpack is recommended.


wkhtmltopdf-buildpack has it's binary paths slightly different than standard ubuntu packages. Make sure you set the following env: WKHTMLTOPDF_CMD=/app/bin/wkhtmltopdf and WKHTMLTOPDF_VERSION=0.12.4

Gettext and heroku

Django requires gettext to be installed for using the built in i18n mechanics. heroku-buildpack-gettext proved working with no troubles.