22
loading...
This website collects cookies to deliver better user experience
requirements.txt
at the root of the project to add all dependencies with their versions.freeze
command on your terminal at the project root directorypip freeze > requirements.txt
requirements.txt
file will have every library that you installed on the computer. Also, mostly the Django project doesn't need those other libraries. So there's a way to fix this problem that I would recommend. You have to install a simple library called pipreqs.pip install pipreqs
pipreqs <your-project-location>
Successfully saved requirements file in <your-project-location>/requirements.txt
settings.py
file.STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Procfile
at the root of the project. (do not add any file extension like .txt .py). The file name must be only Procfile
).Procfile
.web: gunicorn <your-project-name>.wsgi
Procfile
requires Gunicorn
, the production web server that Heroku recommend for Django applications.pip install gunicorn
pip install django-heroku
settings.py
import django_heroku top of the file.import django_heroku
settings.py
file to activate django-heroku.django_heroku.settings(locals())
git init
git add .
git commit -m "first commit"
heroku login
heroku create <your-app-name>
git push heroku master
heroku open
heroku run python manage.py migrate
settings.py
file.DEBUG = False
ALLOWED_HOSTS = ['<your-app-name>.herokuapp.com', 'localhost', '127.0.0.1']
git add .
git commit -m "settingspy edited"
git push heroku master