Django Heroku Deployment Steps

||
Posted 1 year, 4 months ago
||
Views 165
||
2 min read
0 reactions

Create the App in Heroku  using below URL,

https://dashboard.heroku.com/apps

Step 1:

heroku login

Step 2:

Navigate to the Django Project folder where manage.py resides

Step 3:

git init

Step 4:

heroku git:remote -a <app_name>

Step 5:

Create Procfile in PROJECT_HOME dir

Step 6:

pip install gunicorn

Step 7:

pip install django-heroku

Step 8:

import django_heroku

Add the following import statement to the top of settings.py:

Step 9:

Then add the following to the bottom of settings.py:

django_heroku.settings(locals())

Step 10:

Django does not support serving static files in production. However, the fantastic WhiteNoise project can integrate into your Django application, and was designed with exactly this purpose in mind.

pip install whitenoise

Step 11:

Next, install WhiteNoise into your Django application. This is done in settings.py’s middleware section (at the top):

MIDDLEWARE_CLASSES = (
    # Simplified static file serving.
    # https://warehouse.python.org/project/whitenoise/
    'whitenoise.middleware.WhiteNoiseMiddleware',
)

Step 12:

Finally, if you’d like gzip functionality enabled, also add the following setting to settings.py

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

Step 13:

If collectstatic failed during a build, a traceback was provided that will be helpful in diagnosing the problem. If you need additional information about the environment collectstatic was run in, use the DEBUG_COLLECTSTATIC configuration.

heroku config:set DEBUG_COLLECTSTATIC=1

Step 14:

Sometimes, you may not want Heroku to run collectstatic on your behalf. You can disable the collectstatic build step with the DISABLE_COLLECTSTATIC configuration:

heroku config:set DISABLE_COLLECTSTATIC=1

Step 15:

git add .

Step 16:

git commit -am "Initial commit"

Step 17:

git push heroku master

Happy Coding !!!


0 reactions

Discussion

scott
Posted 1 year, 4 months ago

if anyone stuck on deployment. You may raise the ticket in our developer portal Developer Portal. Team will guide you on this.


Đfggffdd

- tt0322816 Posted 1 year, 4 months ago

ok

- bhanupriyakuchana123 Posted 1 year ago

bhanupriyakuchana123
Posted 1 year ago

the install explaination is good



Actively looking for JOBS
Joined on April 15, 2020


Latest Videos


Wanna Post Ad?
Reach a large group of audience by posting an ad about your business here. For more details
Drop us a Message