Django News App Deployment On Heroku
Tags: python, django, webdev, backend
Published: 2020-09-30 16:46:32

Yesterday I write a post about **[Building a News App in django](https://dev.to/magesh236/news-app-in-django-2dcd)**, you can find it here
### https://dev.to/magesh236/news-app-in-django-2dcd

Now we are going to deploy this [django app](https://dev.to/magesh236/news-app-in-django-2dcd) on [heroku](https://www.heroku.com/)

This is the first time I'm trying to deploy [django](https://www.djangoproject.com/) app on [heroku](https://www.heroku.com/)

Go to the [heroku](https://www.heroku.com/) 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](https://dev-to-uploads.s3.amazonaws.com/i/lqgwkpag1jco0d2yeo8y.png)

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cralr30tfxi5a22gilo4.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/1fqtyq0c2j71b89xb5gy.png)

Instructions to deploy apps in **heroku**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/atznsr0rs0yu81usws7h.png)

We will use [heroku](https://www.heroku.com/) cli to deploy the project, install the [heroku cli](https://devcenter.heroku.com/articles/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
```

To check heroku is installed, use the heroku --version command
```
   heroku --version
   heroku/7.43.2 darwin-x64 node-v12.16.2
```

login to heroku cli using this command
```
   heroku login
```

go to the root directory of the project in this case newsapp directory
```
   cd newsapp
```
and then initialize a git repository 
```
   git init
   heroku git:remote -a APPNAME
```

same as git, commit the code
```
   git add .
   git commit -am "first commit"
```

Deploy your application
```
   git push heroku master
```
[you may get error in this, You can now change your main deploy branch from "master" to "main" for both manual and automatic deploys.](https://help.heroku.com/O0EXQZTA/how-do-i-switch-branches-from-master-to-main)

create a new branch called main
```
   git checkout -b main
```

if you want you can delete the old branch
```
   git branch -D master
```
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](https://stackoverflow.com/questions/36665889/collectstatic-error-while-deploying-django-app-to-heroku)
```
   heroku config:set DISABLE_COLLECTSTATIC=1
```

### Deploy News App Application
```
   git push heroku main
```
you can see the status in terminal or in Activity Feed

We made it.... Our app is live.
![party](https://media.giphy.com/media/6nuiJjOOQBBn2/giphy.gif)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/36lq9exrt01h1f3vli3f.png)

Don't forget to check this post **[Building a News App in django.](https://dev.to/magesh236/news-app-in-django-2dcd)**

Thanks you, have a great day ahead.🤪😎