Skip to main content

django-production gets your project production ready

Project description

django-production

Opinionated one-size-fits-most defaults for running Django to production (or any other deployed environment).

Installation

pip install django-production
DJANGO_SETTINGS_MODULE=yourproject.settings django-production-apply

What it does

When you install the package, it will install the following dependencies:

  • whitenoise - for serving static files
  • django-environ - for reading settings from environment variables
  • django-webserver[gunicorn] - for running the webserver via manage.py
  • django-alive - for a health check endpoint at /-/alive/

Running django-production-apply will append the django-production settings to your project's settings file.

You should add django-production to your requirements to keep the necessary dependencies in place. Alternatively, once the patch is applied, you're free to move the dependencies into your own requirements file and remove django-production altogether.

Running in production

Required environment variables

  • DJANGO_ENV - set to production to enable production settings
  • SECRET_KEY - a secret key for your project

Optional environment variables when using DJANGO_ENV=production

Answers

You didn't ask any questions, but if you did, maybe it would be one of these:

Why did you write this? Django takes an un-opinionated approach to how it should be deployed. This makes it harder for new users. Even experienced users probably copy this from project-to-project. This aims to make it easy to get a project ready to deploy. I also hope it will give us a chance to create some consensus around these settings as a community and maybe start folding some of this into Django itself.

Why are you writing to my settings file? You could just just do an import.

  1. It makes it easier to see the changes. I'm of the opinion that settings files should be as simple as possible. Having the settings right there makes it easier to debug.
  2. A one-size-fits-all approach will never work here. I'm shooting for one-size-fits-most. Users are free to make changes however they see fit once the change is applied. It's basically what startproject is already doing.

I disagree with the settings/packages you're using. Not a question, but ok. Feel free to submit an issue or pull request with your suggestion and reasoning. We appreciate the feedback and contributions. We may not accept changes that we don't feel fit the spirit of this project (remember, it's opinionated). If you're unsure, don't hesitate to ask.

To Do

  • Handle media settings for common object stores
  • Email settings including non-SMTP backends like SES

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-production-0.0.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

django_production-0.0.2-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-production-0.0.2.tar.gz.

File metadata

  • Download URL: django-production-0.0.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for django-production-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0c17ae8b079da3f5361417c112268c82ff5e85ca48e925bb3ac4e3273030a38d
MD5 0b614ea15c935d06dec4d2c7eec55da4
BLAKE2b-256 dfa98db5ce68e935158bf4aa2436648bc0cf51f23f689f8ab46f1bc6e5dd4413

See more details on using hashes here.

File details

Details for the file django_production-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_production-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 35c5ab846fc92387de72add4028a805b66cab3ec76355bb4d74e1d5c4b2a80aa
MD5 b99092268fbab8cae456b6637f255d1c
BLAKE2b-256 d689bd38fcf676bfba0bf00b4fc5d6f434e3ed9264eea426160dcb42ccc5607e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page