contact@digitalnotebooks.co
Stay Organized, Stay Inspired. Let's Write.

Car Listing: Deployment using Heroku Part 19A

Back To All Notes
  • Notebook: Django Project: Car Listing
  • Speaker:
  • Date Created: July 25, 2024, 7:54 p.m.
  • Owner: Rosilie

1. Dump or create a copy of your PostgreSQL dtabase and its records into a JSON file. We issue the command below in our GitBash Terminal

$ python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 4 > project_dump.json

This will produce a new file called PROJECT_DUMP.JSON that contains all the models and the records we have made.

2.  Now, to deploy the project in HEROKU, create a new account in HEROKU.

3.  Update your .GITIGNORE FILE, remove the following from the .GITIGNORE file:

MEDIA

STATIC (ONLY IF YOU FOUND IT. IN OUR CASE, THERE IS NONE)

4.  Create new files called runtime.txt and Procfile in the root directory.

5.  In the Procfile file, type the following. Carzone here is the name that we we see in CARZONE\WSGI.PY file. So, if your project name is different, then update accordingly.

release: python manage.py migrate
web: gunicorn carzone.wsgi

6. In the RUNTIME.TXT, we type the version of Python that we used.

To find out your Python version, type 

7. Update our REQUIREMENTS.TXT by using the code below:

$ pip freeze > requirements.txt

8. Use this HEROKU DOCUMENTATION as a guide. We need to INSTALL HEROKU CLI.

We get inside our project folder and open GitBash here. PREVIOUSLY, WHAT YOU HAVE BEEN USING WAS THE GITBASH TERMINAL IN VS CODE.

9. In the GitBash terminal, make sure you activate your virtual environment.

$ source env/Scripts/activate
 

10. Now, when you type HEROKU LOGIN in the terminal, you should be able to use this:

11. This should open the HEROKU CLI PAGE:

Click LOGIN. If you were not currently logged in Heroku, you will need to login using your email address and password.

12. Press CTRL+C to terminate from the HEROKU INTERFACE to install GUNICORN. Type N'

13. To know who is the logged in user or if you have logged out. Type

14. Install the 2 packages, GUNICORN and PSYCOPG2-BINARY.  If you open your DIGITAL NOTEBOOK PROJECTS, these are the packages that were used too since both projects use PostgreSQL.

$ pip install gunicorn psycopg2-binary

15. With the newly installed packages, update your REQUIREMENTS.TXT using PIP FREEZE.

16. See the next part in Heroku deployment.

 



No PDF file attached.

Notebook
Notebook Details
Title: Django Project: Car Listing
Category: Udemy Django Course