Django Deployment to Github

Github is a global repository system which is used for version control. While working with django, if there is need for version management, it is recommended to use github.

In this tutorial, we will create and deploy a django project to the github so that it can be accessible globally.

Before deploying, it is required to have a github account, otherwise create an account first by visiting github.com.

Open the terminal and cd into the project, we want to deploy. For example, our project name is djangoboot. Then

Install Git

we use the following command to install git on our location machine.

Initialize Git

Use the following command to start the git.

Django Initialize Git

Provide global user name email for the project, it is only once, we don?t need to provide it repeatedly.

Django Initialize Git 1

Create File

Create a file .gitignore inside the root folder of django project. And put the following code inside it.

// .gitignore

Git Status

Check the git status by using the following command. It provides some detail to the screen.

Django Git Status

After saving, now execute the following command.

Django git add all

Push to Github

First login into the git account and create a new repository and initialize with README. See the example.

Django Push to Github

My repository name is my-django-app. Click on the create repository button. Now repository has created.

On next page, click on the clone button and copy the http url. In my case, it is https://github.com/irfan003/my-django-app.git

Now, use this url with the following command.

Django git push u force origin master

provide username and password of git account. It will start pushing project to the repository. We can verify it. See the below screenshot.

my django app

See, our django application has deploy successfully on github. Now, we can access it globally.