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.

snippet
$ apt-get install git

Initialize Git

Use the following command to start the git.

snippet
$ git init
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

snippet
*.pyc
*~
__pycache__
myvenv
db.sqlite3
/static
.DS_Store

Git Status

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

snippet
$ git status
Django Git Status

After saving, now execute the following command.

snippet
$ git add -all
snippet
$ git commit -m "my app first commit"
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.

snippet
$ git remote add origin https://github.com/irfan003/my-django-app.git
snippet
$ git push -u --force origin master
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.

Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +