{"id":17873981,"url":"https://github.com/nigma/heroku-django-cookbook","last_synced_at":"2025-10-24T12:34:53.965Z","repository":{"id":4709568,"uuid":"5857306","full_name":"nigma/heroku-django-cookbook","owner":"nigma","description":"Collection of snippets that solve certain problems while deploying Django apps to Heroku","archived":false,"fork":false,"pushed_at":"2015-05-02T17:01:12.000Z","size":176,"stargazers_count":128,"open_issues_count":4,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T14:11:53.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nigma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-18T14:07:26.000Z","updated_at":"2023-12-08T14:02:57.000Z","dependencies_parsed_at":"2022-09-25T02:11:44.587Z","dependency_job_id":null,"html_url":"https://github.com/nigma/heroku-django-cookbook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigma%2Fheroku-django-cookbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigma%2Fheroku-django-cookbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigma%2Fheroku-django-cookbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigma%2Fheroku-django-cookbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nigma","download_url":"https://codeload.github.com/nigma/heroku-django-cookbook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246911489,"owners_count":20853654,"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":[],"created_at":"2024-10-28T11:07:11.190Z","updated_at":"2025-10-24T12:34:48.926Z","avatar_url":"https://github.com/nigma.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Django and Heroku Cookbook\n==========================\n\nCollection of snippets and scripts that solve certain problems when deploying\nDjango apps to Heroku.\n\nScripts in the `bin` directory are post-compile hooks that are invoked by\nthe `heroku-buildpack-python`'s\n[compile](https://github.com/heroku/heroku-buildpack-python/blob/master/bin/compile)\nstep. You can install them by copying the `bin` directory into the root\ndirectory of your Heroku application repository.\n\nInstalling NodeJS and Less compiler for static assets compilation in your Django app\n------------------------------------------------------------------------------------\n\nHeroku provides a bunch of different\n[buildpacks](https://devcenter.heroku.com/articles/buildpacks) that target many\npopular platforms like Python, Ruby, NodeJS and Java web apps and backends.\nWhile this is great and allows you to deploy virtually anything with a simple\ngit command, the out-of-the-box solutions offer a limited set of utilities\nthat are available during the\n[Slug compilation](https://devcenter.heroku.com/articles/slug-compiler) phase.\nIn particular no NodeJS, NPM or [LESS Compiler](http://lesscss.org/)\nis available in the `heroku-buildpack-python`. This means that there\nis no straightforward way of compiling `.less` stylesheets during\nthe app deployment.\n\nFortunately, the Python buildpack provides hooks for running pre-compile\nand post-compile scripts. This can be used for customizing the compilation\nstep and running additional commands without the necessity of maintaining\na separate fork of Heroku's buildpack.\nThe only thing you need to do is to create a proper `bin/post_compile` bash\nscript in the root directory of your application.\n\nThe [bin](https://github.com/nigma/heroku-django-cookbook/tree/master/bin) and\n[.heroku](https://github.com/nigma/heroku-django-cookbook/tree/master/.heroku) directories\ncontain a set of scripts that can be used to install NodeJS/Less and invoke\n`manage.py collectstatic` and `manage.py compress` commands in your Django application:\n\n- [bin/post_compile](https://github.com/nigma/heroku-django-cookbook/tree/master/bin/post_compile)\n- [bin/install_nodejs](https://github.com/nigma/heroku-django-cookbook/tree/master/bin/install_nodejs)\n- [bin/install_less](https://github.com/nigma/heroku-django-cookbook/tree/master/bin/install_less)\n- [bin/run_collectstatic](https://github.com/nigma/heroku-django-cookbook/tree/master/bin/run_collectstatic)\n- [bin/run_compress](https://github.com/nigma/heroku-django-cookbook/tree/master/bin/run_compress)\n- [.heroku/collectstatic_disabled](https://github.com/nigma/heroku-django-cookbook/tree/master/.heroku/collectstatic_disabled)\n\nJust copy them over to your app reposiory and have your Less stylesheets\ncompiled with an assets compressor like\n[Django Compressor](https://github.com/jezdez/django_compressor).\n\nNote: the empty ``/.heroku/collectstatic_disabled`` file deactivates the default collectstatic\nbuild step that is part of the Heroku's buildpack. This will prevent the build script from doing\nunnecessary work that is already handled by the above scripts.\n\nA note on hosting static files on Amazon S3. Remember to enable the\n[environment variables](https://devcenter.heroku.com/articles/django-assets#config-vars-during-build)\nif you are using django-storages and uploading static assets to S3:\n\n`heroku labs:enable user-env-compile`\n\n\nAutomatic Django configuration and utilities for Heroku\n-------------------------------------------------------\n\n[django-herokuify](https://github.com/nigma/django-herokuify) is a Django settings helper\nthat makes is very easy to configure database, cache, storage, email and other\ncommon services for your Django project running on Heroku:\n\n```python\nimport herokuify\n\nfrom herokuify.common import *              # Common settings, SSL proxy header\nfrom herokuify.aws import *                 # AWS access keys as configured in env\nfrom herokuify.mail.mailgun import *        # Email settings for Mailgun add-on\n\nDATABASES = herokuify.get_db_config()       # Database config\nCACHES = herokuify.get_cache_config()       # Cache config for Memcache/MemCachier\n```\n\nSee the [project page](https://github.com/nigma/django-herokuify) for more information.\n\nAll in one\n----------\n\n[Django Modern Template](https://github.com/nigma/django-modern-template) is a project\ntemplate for easy bootstrapping a Django project that can be deployed on Heroku.\n\nClean virtualenv\n----------------\n\nHeroku caches Python virtual environment and all installed packages between\nproject deploys.\n\nSince the ``CLEAN_VIRTUALENV`` flag has been removed from the buildpack,\ncurrently the only way to clean app cache is by\n[changing the runtime](https://devcenter.heroku.com/articles/python-runtimes#changing-runtimes).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnigma%2Fheroku-django-cookbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnigma%2Fheroku-django-cookbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnigma%2Fheroku-django-cookbook/lists"}