Project in Django

D:\lab\batch28>pip install django


In Django, every web app you want to create is called a project;

and a project is a sum of applications.

An application is a set of code files relying on the MVT pattern. As example let's say we want to build a website, the website is our project and, the forum, news, contact engine are applications. This structure makes it easier to move an application between projects since every application is independent.

Create a Project

Whether you are on Windows or Linux, just get a terminal or a cmd prompt and navigate to the place you want your project to be created, then use this code −

$ django-admin startproject myproject

D:\lab\batch28>django-admin startproject myproject

This will create a "myproject" folder with the following structure −


The Project Structure

The “myproject” folder is just your project container, it actually contains two elements −

  • − This file is kind of your project local django-admin for interacting with your project via command line (start the development server, sync db...). To get a full list of command accessible via you can use the code −
$ python help
  • The “myproject” subfolder − This folder is the actual python package of your project. It contains four files −
    • − Just for python, treat this folder as package.
    • − As the name indicates, your project settings.
    • − All links of your project and the function to call. A kind of ToC of your project.
    • − If you need to deploy your project over WSGI.

Setting Up Your Project

Your project is set up in the subfolder myproject/ Following are some important options you might need to set −

DEBUG = True

This option lets you set if your project is in debug mode or not. Debug mode lets you get more information about your project's error. Never set it to ‘True’ for a live project. However, this has to be set to ‘True’ if you want the Django light server to serve static files. Do it only in the development mode.

   'default': {
      'ENGINE': 'django.db.backends.sqlite3',
      'NAME': 'database.sql',
      'USER': '',
      'PASSWORD': '',
      'HOST': '',
      'PORT': '',

Database is set in the ‘Database’ dictionary. The example above is for SQLite engine. As stated earlier, Django also supports −

  • MySQL (django.db.backends.mysql)
  • PostGreSQL (django.db.backends.postgresql_psycopg2)
  • Oracle ( and NoSQL DB
  • MongoDB (django_mongodb_engine)

Before setting any new engine, make sure you have the correct db driver installed.

You can also set others options like: TIME_ZONE, LANGUAGE_CODE, TEMPLATE…

Now that your project is created and configured make sure it's working −

D:\lab\batch28\myproject>python runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python migrate' to apply them.
September 16, 2018 - 15:12:48
Django version 2.1.1, using settings 'myproject.settings'
Starting development server at
Quit the server with CTRL-BREAK.


A project is a sum of many applications. Every application has an objective and can be reused into another project, like the contact form on a website can be an application, and can be reused for others. See it as a module of your project.

Create an Application

We assume you are in your project folder. In our main “myproject” folder, the same folder then −

$ python startapp myapp

You just created myapp application and like project, Django create a “myapp” folder with the application structure −

  • − Just to make sure python handles this folder as a package.
  • − This file helps you make the app modifiable in the admin interface.
  • − This is where all the application models are stored.
  • − This is where your unit tests are.
  • − This is where your application views are.

Get the Project to Know About Your Application

At this stage we have our "myapp" application, now we need to register it with our Django project "myproject". To do so, update INSTALLED_APPS tuple in the file of your project (add your app name) −


3. Start App

D:\django\myproject>python startapp myapp




Install django
pip install django

1. Create project
D:\django>django-admin startproject myproject

Dont change(edit)

D:\django>django-admin startproject website

2. D:\django>cd myproject

3. Start App

D:\django\myproject>python startapp myapp

4. Create Super user D:\django\myproject>python createsuperuser