{"id":16417293,"url":"https://github.com/sesh/django-up","last_synced_at":"2025-04-10T19:14:28.019Z","repository":{"id":39155318,"uuid":"49841663","full_name":"sesh/django-up","owner":"sesh","description":"🚀 Zero configuration Django deployments","archived":false,"fork":false,"pushed_at":"2024-10-20T21:52:56.000Z","size":104,"stargazers_count":99,"open_issues_count":5,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-02-12T00:36:35.626Z","etag":null,"topics":["ansible","deployment","devops","django","letsencrypt","python"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-18T00:02:01.000Z","updated_at":"2025-01-18T23:42:08.000Z","dependencies_parsed_at":"2024-10-21T01:27:58.897Z","dependency_job_id":null,"html_url":"https://github.com/sesh/django-up","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fdjango-up","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fdjango-up/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fdjango-up/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fdjango-up/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sesh","download_url":"https://codeload.github.com/sesh/django-up/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248280575,"owners_count":21077415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","deployment","devops","django","letsencrypt","python"],"created_at":"2024-10-11T07:11:25.124Z","updated_at":"2025-04-10T19:14:27.992Z","avatar_url":"https://github.com/sesh.png","language":"Jinja","funding_links":[],"categories":["Jinja"],"sub_categories":[],"readme":"# django-up\n\n`django-up` is a tool to quickly deploy your Django application to a Ubuntu 22.04 server with almost zero configuration.\n\n```shell\npython manage.py up django-up.com --email=\u003cyour-email\u003e\n```\n\nRunning `django-up` will deploy a production ready, SSL-enabled, Django application to a VPS using:\n\n- Nginx\n- Gunicorn\n- PostgreSQL\n- SSL with acme.sh (using Let's Encrypt)\n- UFW\n- OpenSMTPd\n\n\n## Supporting this project\n\nThe easiest way to support the development of this project is to use [my Linode referal code][linode] if you need a hosting provider.\nBy using this link you will receive a $100, 60-day credit once a valid payment method is added.\nIf you spend $25 I will receive $25 credit in my account.\n\n`django-up` costs around $7/month to host on Linode, referrals cover that cost, plus help to support my other projects hosted there. I've used various hosting providers over the years but Linode is the one that I like the most.\n\n_This is the only place where referral codes are used. All other links in the documentation will take you to the services without my reference._\n\n\n## Quick Start (with Pipenv)\n\nCreate a new VPS with your preferred provider and update your domain's DNS records to point at it.\nCheck that you can SSH to the new server as `root` before continuing.\n\nEnsure that `ansible` is installed on the system your are deploying from.\n\nCreate a directory for your new project and `cd` into it:\n\n```shell\nmkdir testproj\ncd testproj\n```\n\nInstall Django, PyYAML and dj_database_url:\n\n```shell\npipenv install Django pyyaml dj_database_url\n```\n\nStart a new Django project:\n\n```shell\npipenv run django-admin startproject testproj .\n```\n\nRun `git init` to initialise the new project as a git repository:\n\n```shell\ngit init\n```\n\nAdd `django-up` as a git submodule:\n\n```shell\ngit submodule add git@github.com:sesh/django-up.git up\n```\n\nAdd `up` to your `INSTALLED_APPS` to enable the management command:\n\n```python\nINSTALLED_APPS = [\n  # ...\n  'up',\n]\n```\n\nAdd your target domain to the `ALLOWED_HOSTS` in your `settings.py`.\n\n```python\nALLOWED_HOSTS = [\n  'djup-test.brntn.me',\n  'localhost'\n]\n```\n\nSet the `SECURE_PROXY_SSL_HEADER` setting in your `settings.py` to ensure the connection is considered secure.\n\n```python\nSECURE_PROXY_SSL_HEADER = ('HTTP_X_SCHEME', 'https')\n```\n\nSet up your database to use `dj_database_url`:\n\n```python\nimport dj_database_url\nDATABASES = {\n    'default': dj_database_url.config(default=f'sqlite:///{BASE_DIR / \"db.sqlite3\"}')\n}\n```\n\nGenerate a new secret key (either manually, or with a [trusted tool](https://utils.brntn.me/django-secret/)), and configure your application to pull it out of the environment.\n\nIn `.env`:\n\n```\nDJANGO_SECRET_KEY=\u003cyour unique secret key\u003e\n```\n\nAnd in your `settings.py` replace the existing `SECRET_KEY` line with this:\n\n```\nSECRET_KEY = os.environ[\"DJANGO_SECRET_KEY\"]\n```\n\nCreate a requirements file from your environment if one doesn't exist:\n\n```shell\npipenv requirements --exclude-markers \u003e requirements.txt\n```\n\nDeploy with the `up` management command:\n\n```shell\npipenv run python manage.py up yourdomain.example --email=\u003cyour-email\u003e\n```\n\n\n## Extra Configuration\n\n### Setting environment variables\n\nAdd environment variables to a `.env` file alongside your `manage.py`. These will be exported into the environment before running your server (and management commands during deployment).\n\nFor example, to configure Django to load the `SECRET_KEY` from your environment, and add a secure secret key to your `.env` file:\n\n`settings.py`:\n\n```python\nSECRET_KEY = os.environ[\"DJANGO_SECRET_KEY\"]\n```\n\n`.env`:\n\n```\nDJANGO_SECRET_KEY=\"dt(t9)7+\u0026cm$nrq=p(pg--i)#+93dffwt!r05k-isd^8y1y0\"\n```\n\n\n### Specifying a Python version\n\nBy default, `django-up` uses Python 3.8.\nIf your application targets a different version you can use the `UP_PYTHON_VERSION` environment variable.\nValid choices are:\n\n- `python3.8`\n- `python3.9`\n- `python3.10` (default)\n- `python3.11`\n\n```python\nUP_PYTHON_VERSION = \"python3.11\"\n```\n\nThese are the Python version available in the deadsnakes PPA.\nVersions older than Python 3.8 require older versions of OpenSSL so are not included in the PPA for Ubuntu 22.04.\n\n\n### Deploying multiple applications to the same server\n\nYour application will bind to an internal port on your server.\nTo deploy multiple applications to the same server you will need to manually specify this port.\n\nIn your `settings.py`, set `UP_GUNICORN_PORT` is set to a unique port for the server that you are deploying to:\n\n```python\nUP_GUNICORN_PORT = 8556\n```\n\n\n### Using manifest file storage\n\nTo minimise downtime, during the deployment `collectstatic` is executed while your previous deployment is still running.\nIn order make sure that the correct version of static files are used _during the deployment_ you can use the `ManifestStaticFilesStorage` storage backend that Django provides.\n\n```python\nSTATICFILES_STORAGE = \"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"\n```\n\nFor most projects using this backend will be a best practice, regardless of whether you are deploying with `django-up`.\n\n\n### Supporting multiple domains\n\nAs long as all domains that you plan on supporting are pointing to your server, you can include them in your `ALLOWED_HOSTS`.\nCertificates will be requested for each domain.\n\nFor example, so support both the apex and `www` subdomain for a project, your could configure your application with:\n\n```python\nALLOWED_HOSTS = [\n  'django-up.com',\n  'www.django-up.com'\n]\n```\n\n\n### Adding `django-up` directly to your project\n\nIf you are likely to customise the Ansible files then it's probably easier to just add the `django-up` files to your own git repository, rather than using a submodule.\n\nYou can use a shell one liner to download the repository from Github and extract it into an \"up\" directory in your project:\n\n```shell\nmkdir -p up \u0026\u0026 curl -L https://github.com/sesh/django-up/tarball/main | tar -xz --strip-components=1 -C up\n```\n\n\n  [django]: https://www.djangoproject.com\n  [linode]: https://www.linode.com/lp/refer/?r=46340a230dfd33a24e40407c7ea938e31b295dec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsesh%2Fdjango-up","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsesh%2Fdjango-up","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsesh%2Fdjango-up/lists"}