Skip to main content

Deploy django project on heroku

Deploying your Flask Application to Heroku | by Emmanuel King Kasulani |  The Andela Way | Medium

 check heroku

-------------------------------------

heroku --version

----------------------------------------

In django project 

$ pip3 install gunicorn

$ pip install django-heroku

$ pip install  python-decouple

then,

$ touch Procfile

 edit this procfile

--------------------------------------------------

web: gunicorn sample.wsgi

sample means very first project wsgi.py file

$ pip freeze > requirements.txt

----------------------------------------------------

import those things in settings.py file 

---------------------

import django_heroku
import dj_database_url
from decouple import config

Add middleware

'whitenoise.middleware.WhiteNoiseMiddleware',
 --------------------------------------------------
 bottom of settings.py file
 
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
----------------------------
then,
django_heroku.settings(locals())
 
push github
-------------
login heroku 
$heroku login
 
----------------------
$ heroku keys:add
 
----------------------
$ heroku create 

rename 
-------------
heroku rename app_name

-----------------

$ heroku config:set DISABLE_COLLECTSTATIC=1
---------------
$ git push heroku master
 
 
 
after push make migrate
-------------------------------
heroku run python manage.py migrate 
heroku run python manage.py createsuperuser


 
 

Comments

Popular posts from this blog

Connect POSTgreSQL with Django

  First install all necessary step  $ sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib Second $ sudo su - postgres $ psql Create User name with password  $ CREATE USER user_name WITH PASSWORD ' password ';   Create New Database $ CREATE DATABASE database_name WITH OWNER user_name ; Give permission  $ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user_name ; Update settings.py  DATABASES = { ' default ' : { ' ENGINE ' : ' django.db.backends.postgresql_psycopg2 ' , ' NAME ' : 'database_name ' , ' USER ' : ' user_name ' , ' PASSWORD ' : ' password' , ' HOST ' : ' localhost ' , ' PORT ' : ' 5432 ' , } }  Then, python3 manage.py migrate and finally create super user python3 man age.py createsuperuser