Starting A Django Project

3 min read

Django is one of the most popular open source full-stack web development Framework written in Python. Django is a framework for perfectionists with deadlines, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel.

To know more about Django read: Django – Web Framework For Perfectionists

In this article, we will go over the steps for creating and running a Django Project.

Creating A Django Project

A project is a collection of settings for an instance of Django including database configuration, Django-specific options, and application-specific settings.

Before creating a Django project make sure you have Python and Django installed in your machine if not go through How To Install Django

It is recommended to create projects in virtual environments though it's optional using them will save you from a lot of headaches in the future. Read the following article to know why virtual environments are so important: How To A Create Virtual Environment for Python

Note that, I am assuming that you have activated your virtual environment where your Django installation exists. Next, run the below command.

django-admin startproject mysite

This command will invoke the script, which will set up a new Django project called mysite. A Django project name can be composed of numbers, letters, or underscores. A project name cannot start with a number, it can only start with a letter or underscore in addition special characters and spaces aren't allowed anywhere in a project name.

You’ll now notice within your workspace there is a directory set to the name of your new project, mysite. Inside the directory, there is another directory with the same name as the project and a python script named

Inside the second level project directory, there are another 4 Python scripts. So the default Django project can be illustrated as follows.

   mysite/ -  a blank Python script whose presence indicates to the Python interpreter that the directory is a Python package. This file allows Python packages to be imported from the directories they are present. - Contains the configuration settings for the Django project. - Contains URL patterns for the Django project. - Contains WSGI configuration properties for the Django project. Basically, Python script used to help run your development server and deploy your project to a production environment. -  a command-line utility that lets you interact with your Django project in many ways. This script is responsible for all project specific tasks.

Note that, there are two directories with the project name, this might seem confusing at first however you can always change the name of the outer directory which occasionally referred to as the Base Directory. The second level project directory is hardcoded in some of the Django specific files so better not mess with it.

Running A Django Project

Now that we have created a Django project we can see it in action in the browser. Django comes with a built-in web server for development. Navigate to the Base directory where is, and run the below command.

python runserver

Ignore all the migration errors for the moment, Now open your preferred browser and go to If everything went right you should see the default the page of Django.Starting A Django Project

To stop the server press ctrl + c in the terminal window. Running the application on a different port is also possible you just need to pass the port number along with the command.

# Run the development server on the local address and port 4345 (
python runserver 4345

# Run the dev server on the address and port 80 (
python runserver


Latest Articles

Latest from djangocentral

Django 4.1 adds async-compatible interface to QuerySet

The much-awaited pull request for an async-compatible interface to Queryset just got merged into the main branch of Django.Pull Request - The Django core team has been progressively adding async suppor…
Read more →

3 min read

Making Django Admin Jazzy With django-jazzmin

Django admin is undoubtedly one of the most useful apps of Django. Over the years there has been very little change in the admin app as far as the UX is concerned and it's not a bad thing at all. Django admin was designed to provide a simple and minimali…
Read more →

4 min read