Skip to content

Instantly share code, notes, and snippets.

@robertowest
Last active May 12, 2020 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertowest/01717ad91f980c6f2a8b8d1763468e46 to your computer and use it in GitHub Desktop.
Save robertowest/01717ad91f980c6f2a8b8d1763468e46 to your computer and use it in GitHub Desktop.
Heroku

Notas para subir un proyecto a heroku

Crea nuevo proyecto

$ cd ../Python/
$ mkdir heroku
$ cd heroku/

Creamos y conectamos a nuestro environment

$ python3 -m venv .env
$ source .env/bin/activate

Creamos nuestro proyecto django 2.2

$ django-admin startproject config .
$ ./manage.py migrate
$ ./manage.py createsuperuser
$ ./manage.py runserver

Creamos nuestro proyecto heroku

$ heroku login
$ heroku create lubresrl --buildpack heroku/python

Creamos nuestro archivo .gitignore

En mi caso, deseo ignorar venv, python y visualstudiocode

Siga este enlace para generar el archivo .gitignore

Creamos repositorio git y preparamos primera carga

$ git init
$ git add --all .
$ git commit -m "primera subida a Heroku"

Enlazamos el proyecto heroku a git

$ heroku git:remote -a lubresrl

Realizamos nuestro primer checkin

previamente, desabilitamos collectstatic

$ heroku config:set DISABLE_COLLECTSTATIC=1
$ git push heroku master

Siguientes modificaciones ...

$ git add --all .
$ git commit -m "modificaciones en Heroku"
$ git push [heroku master]

Conectarse a la base de datos Heroku desde psql

$ heroku pg:psql

psql>\dt
psql>select * from homepage_entries;
psql>\q

Modificaciones al proyecto Django

Realizamos las modificaciones necesarias para que nuestro proyecto django funcione correctamente en Heroku

$ pip install django $ pip install gunicorn $ pip install psycopg2 $ pip install dj-database-url $ pip install python-decouple $ pip install whitenoise $ pip freeze > requirements.txt

$ django-admin startproject config . $ mkdir static $ touch static/.keep

creamos el archivo Procfile modificamos nuestro settings (https://codigofacilito.com/articulos/deploy-django-heroku)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment