Hi,
I try to explain how to deploy your django project to heroku.
First i want to talk about heroku
Heroku is a cloud application platform. It means you can easly build and deploy your web applications to Heroku servers.
Heroku makes you focus to your application code. It figures out build, deploy and manage server for you.
Heroku support Ruby, Python, Node.js, Java languages.
Lets start to deployment.
First go to heroku homepage and create an account. (free)
Then install heroku to your computer.
brew install heroku
*for manuel download https://toolbelt.heroku.com/
Login to heroku after installation,
heroku login
Enter your Heroku credentials. Email: [email protected] Password (typing will be hidden): Authentication successful.
Now you can start to use heroku commands.
Before deployment you need to create a project on heroku. It is easy run this command
heroku create projectname
* if you dont write a project name, heroku will create your project with random name.
You need to switch your database to postgress if you are using any different.
Add dj-database-url to your requirements.txt than update your settings.py
# Parse database configuration from $DATABASE_URL import dj_database_url DATABASES['default'] = dj_database_url.config()
To serving static files you can use whitenoise.
pip install whitenoise pip freeze > requirement.txt
add this lines on your settings.py
# Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.7/howto/static-files/ STATICFILES_STORAGE = ‘whitenoise.django.GzipManifestStaticFilesStorage'
update your wsgi.py
from django.core.wsgi import get_wsgi_application from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application() application = DjangoWhiteNoise(application)
When you deploy your project to collectstatic will run automatically.
Everything is done, now we can deploy the django project to heroku.
git push heroku master
After deployment, open your project and see it on browser
heroku open
heroku home - https://www.heroku.com/home about heroku - https://www.heroku.com/about deployment - https://devcenter.heroku.com/articles/getting-started-with-python#introduction serv static files - https://devcenter.heroku.com/articles/django-assets