Django News App Deployment On Heroku

max236

Mageshwaran

Posted on September 30, 2020

Django News App Deployment On Heroku

Yesterday I write a post about Building a News App in django, you can find it here

https://dev.to/magesh236/news-app-in-django-2dcd

Now we are going to deploy this django app on heroku

This is the first time I'm trying to deploy django app on heroku

Go to the heroku and signup as a new user, after activating the account you will be redirected to dashboard, it will ask you to create app

Alt Text

after this will you get page like this, with the details how to deploy the project

Alt Text

click the open app, then it will prompt to the url where you will access the news app, for now you will see the default content.
Alt Text

Instructions to deploy apps in heroku
Alt Text

We will use heroku cli to deploy the project, install the heroku cli using this command, i'm using mac it may vary for you, depends which operating system you are using

   brew tap heroku/brew && brew install heroku
Enter fullscreen mode Exit fullscreen mode

To check heroku is installed, use the heroku --version command

   heroku --version
   heroku/7.43.2 darwin-x64 node-v12.16.2
Enter fullscreen mode Exit fullscreen mode

login to heroku cli using this command

   heroku login
Enter fullscreen mode Exit fullscreen mode

go to the root directory of the project in this case newsapp directory

   cd newsapp
Enter fullscreen mode Exit fullscreen mode

and then initialize a git repository

   git init
   heroku git:remote -a APPNAME
Enter fullscreen mode Exit fullscreen mode

same as git, commit the code

   git add .
   git commit -am "first commit"
Enter fullscreen mode Exit fullscreen mode

Deploy your application

   git push heroku master
Enter fullscreen mode Exit fullscreen mode

you may get error in this, You can now change your main deploy branch from "master" to "main" for both manual and automatic deploys.

create a new branch called main

   git checkout -b main
Enter fullscreen mode Exit fullscreen mode

if you want you can delete the old branch

   git branch -D master
Enter fullscreen mode Exit fullscreen mode

in this project deployment I'm not using the static files so I'm disabling it, for further reference check here Collectstatic error while deploying Django app to Heroku

   heroku config:set DISABLE_COLLECTSTATIC=1
Enter fullscreen mode Exit fullscreen mode

Deploy News App Application

   git push heroku main
Enter fullscreen mode Exit fullscreen mode

you can see the status in terminal or in Activity Feed

We made it.... Our app is live.
party

Alt Text

Don't forget to check this post Building a News App in django.

Thanks you, have a great day ahead.🤪😎

💖 💪 🙅 🚩
max236
Mageshwaran

Posted on September 30, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related