pg_config for django_heroku

  1. Install django_heroku: pip install django-heroku

  2. Add django_heroku to your requirements.txt or pipenv: echo "django-heroku==0.3.1" >> requirements.txt

  3. Add django_heroku to your requirements.txt or pipenv: python # settings.py import django_heroku django_heroku.settings(locals())

  4. Install the psycopg2-binary package: pip install psycopg2-binary

  5. Add psycopg2-binary to your requirements.txt or pipenv: echo "psycopg2-binary==2.9.1" >> requirements.txt

  6. Install dj-database-url: pip install dj-database-url

  7. Add dj-database-url to your requirements.txt or pipenv: echo "dj-database-url==0.5.0" >> requirements.txt

  8. Configure your DATABASE_URL in the environment: bash export DATABASE_URL=your_database_url_here

  9. Update your DATABASES setting in settings.py: ```python # settings.py import dj_database_url

DATABASES = { 'default': dj_database_url.config(default=os.environ.get('DATABASE_URL')) } ```

  1. Install the gunicorn package: pip install gunicorn

  2. Add gunicorn to your requirements.txt or pipenv: echo "gunicorn==20.1.0" >> requirements.txt

  3. Create a Procfile in your project root: web: gunicorn your_project_name.wsgi

  4. Install the whitenoise package: pip install whitenoise

  5. Add whitenoise to your requirements.txt or pipenv: echo "whitenoise==5.3.0" >> requirements.txt

  6. Update your MIDDLEWARE setting in settings.py: python # settings.py MIDDLEWARE = [ # ... 'whitenoise.middleware.WhiteNoiseMiddleware', # ... ]

  7. Configure static file handling in settings.py: python # settings.py STATIC_URL = '/static/' STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

  8. Set the DISABLE_COLLECTSTATIC environment variable: bash export DISABLE_COLLECTSTATIC=1

  9. Add python-decouple to your requirements.txt or pipenv: echo "python-decouple==3.5" >> requirements.txt

  10. Configure your static files and media settings using python-decouple in settings.py: ```python # settings.py from decouple import config, Csv

    DEBUG = config('DEBUG', default=False, cast=bool) ```

  11. Install whitenoise for handling static files: pip install whitenoise

  12. Add whitenoise to your requirements.txt or pipenv: echo "whitenoise==5.3.0" >> requirements.txt

  13. Update your MIDDLEWARE setting in settings.py to include whitenoise: python # settings.py MIDDLEWARE = [ # ... 'whitenoise.middleware.WhiteNoiseMiddleware', # ... ]

  14. Configure static file handling in settings.py: python # settings.py STATIC_URL = '/static/' STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

  15. Set the DISABLE_COLLECTSTATIC environment variable: bash export DISABLE_COLLECTSTATIC=1