DigitalOcean Referral Badge
Udit Vashisht
Author: Udit Vashisht

Best way to start a Django project (with Github Integration)

  • 4 minutes read
Best way to start a Django project  (with Github Integration)

    Table of Contents

Correct way to create a Django Project

There are dozens of ways, which developers use to start their Django projects. Possibly, none of them would be a wrong way, but in this post we will be telling you a way which is very helpful and suitable not only in development but also in production (deployment). Not only this, in this post we will teach you how to integrate Git/Github with your project from the very beginning.

Creating the Project Directory

So, let’s get to the work. First of all, I will suggest you to choose a location on your machine (Windows/ Mac), where you want to save most of your projects and cd to that directory. Then create a new directory and cd into that:

$ mkdir dev
$ cd dev

Now, this dev folder will host all of your individual projects. Inside this dev folder create a new directory (with the name of your project/app) and cd into that. This directory will be referred to as your project directory:-

$ mkdir newproject && cd newproject

Creating and activating the Virtual Environment

Install virtual environment and activate it.

$ virtualenv -p python3 .
# or
$ virtualenv .

# Activate on MACOS/Linux
$ source bin/activate

# Activate on Windows

Create a new directory with name ‘src’

$ mkdir src && cd src

Installing Django and starting the project

Use pip to install django

$ pip install django

Now inside the src directory create the project

$ startproject newproject .

You must note the following two things.

  1. We have started a project with name ‘newproject’ and same is the name of the project directory (and also the virtualenv).
  2. There is a trailing . (dot).

Creating local Git repository

Browse to the project folder (i.e. newproject) and run the following command. This will initialize an empty Git repository.

$ git init

Now create a file called .gitignore in the project directory. The function of this file is that, it will not add the folders\files mentioned (pattern) in it to the git repository. This is used for not adding venv, env, temp, db files to the repository.

You can download the standard .gitignore file from here.

Creating a remote Git repository on Github

Open github, log in to your account and create a new repository. Add the name (preferably project name) and description of the repository and create it.

Screenshot 2019-08-06 at 3.36.16 PM.png

You won’t like to share your important credentials on the github etc. For that we will be using Python Decouple.

$ pip install python-decouple

Create a .env file inside the directory where file is (i.e. src)

$ nano .env

Open the file and copy the SECRET_KEY from your


Add the following two lines in your

from decouple import config

Now go to the project directory and check git status to see the files that are untracked

$ git status

You will get something like this

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)


Now, add the files and make initial commit using the following codes:-

$ git add .
$ git commit -m "Initial Commit"

If you will check git status now, it will show the following:

$ git status

On branch master
nothing to commit, working tree clean

Now add the remote origin using this :

git remote add origin

It will ask you for the username and password of the github account and then will push it to Github.

You can check the Github repository here

We also have a one minute video tutorial on our channel

Video Tutorial - Best way to start a Django project (with Github Integration)

Don’t forget to check out our video tutorial on Best way to start a Django project (with Github Integration)

Tags: Django

Related Posts

How to Extend Django User model using AbstractUser?
By Udit Vashisht

Even if the default Django User Model caters to all of your needs, it is highly recommended to use a Custom User Model. Django’s official documentation recommends so. Now there are two ways to create a Custom User Model:-

  1. By extending AbstractBaseUser
  2. By extending ...

    Read More
How to extend Django User model using a proxy model?
By Udit Vashisht

There is no doubt that the built-in user authentication system of Django is quite good and caters the common use cases. But sometimes, we do not have our needs met with out-of-the-box defaults django user model. In such a scenario, we can extend the Django User Model using various methods. ...

Read More
Django Database Migrations: A Comprehensive Overview
By Udit Vashisht

Introduction to Django databases

The Django web framework is designed to work with an SQL-based relational database backend, most commonly PostgreSQL or MySQL. If you’ve never worked directly with a relational database before, managing how your data is stored/accessed and keeping it consistent with your application code ...

Read More
tech tutorials automate python beautifulsoup web scrapping webscrapping bs4 Strip Python3 programming Pythonanywhere free Online Hosting hindi til github today i learned Windows Installations Installation Learn Python in Hindi Python Tutorials Beginners macos installation guide linux SaralGyaan Saral Gyaan json in python JSON to CSV Convert json to csv python in hindi convert json csv in python remove background python mini projects background removal tweepy Django Django tutorials Django for beginners Django Free tutorials Proxy Models User Models AbstractUser UserModel convert json to csv python json to csv python Variables Python cheats Quick tips == and is f string in python f-strings pep-498 formatting in python python f string smtplib python send email with attachment python send email automated emails python python send email gmail automated email sending passwords secrets environment variables if name == main Matplotlib tutorial Matplotlib lists pandas Scatter Plot Time Series Data Live plots Matplotlib Subplots Matplotlib Candlesticks plots Tutorial Logging unittest testing python test Object Oriented Programming Python OOP Database Database Migration Python 3.8 Walrus Operator Data Analysis Pandas Dataframe Pandas Series Dataframe index pandas index python pandas tutorial python pandas python pandas dataframe python f-strings padding how to flatten a nested json nested json to csv json to csv python pandas Pandas Tutorial insert rows pandas pandas append list line charts line plots in python Django proxy user model django custom user model django user model matplotlib marker size pytplot legends scatter plot python pandas python virtual environment virtualenv venv python python venv virtual environment in python python decorators bioinformatics fastafiles Fasta python list append append raspberry pi editor cron crontab Cowin Cowin api python dictionary Python basics dictionary python list list ios development listview navigationview swiftui ios mvvm swift environmentobject property wrapper @State @Environm popup @State ios15 alert automation instagram instaloader texteditor youtubeshorts textfield multi-line star rating reusable swift selenium selenium driver requests-html youtube youtube shorts python automation python tutorial algo trading nifty 50 nifty50 stock list nifty50 telegram telegram bot dictionary in Python how to learn python learn python