Skip to main content

Command Palette

Search for a command to run...

Django Project Setup

project setup for beginners

Updated
3 min read
Django Project Setup
C

Highly motivated tech enthusiast and backend developer with expertise in data analysis, EDA, data preprocessing, and cleaning, as well as building Power BI dashboards. I specialize in creating robust backend systems using Django, designing scalable and maintainable solutions that turn raw data into actionable insights. Passionate about exploring new technologies, I aim to bridge the gap between data-driven insights and real-world applications, while sharing knowledge and tutorials through my blogs.

Django is a powerful Python web framework that helps you build secure, scalable web applications quickly. In this blog, we’ll walk through a complete Django project setup from scratch, using clear commands and best practices.

This guide is perfect if you’re a beginner or setting up a fresh Django project for production or learning.

Prerequisites

Before starting, make sure you have:

  • Python 3.10+ installed

  • Basic knowledge of terminal/command line

  • pip (Python package manager)

Check your Python version:

python --version

Step 1: Create a Project Directory

First, create and move into a new directory for your project.

mkdir django_project
cd django_project

A virtual environment keeps your project dependencies isolated.

python -m venv venv

Activate it:

On Linux / macOS

source venv/bin/activate

On Windows

venv\Scripts\activate

You should now see (venv) in your terminal.

Step 3: Upgrade pip

Always keep pip updated.

pip install --upgrade pip

Step 4: Install Django

Install the latest stable version of Django.

pip install django

Verify installation:

django-admin --version

Step 5: Create a Django Project

Now create your Django project.

django-admin startproject config .

The dot (.) prevents creating an extra nested folder.

Your structure will look like:

django_project/
├── config/
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── asgi.py
│   └── wsgi.py
├── manage.py
└── venv/

Step 6: Run Initial Migrations

Django uses migrations to manage database schema.

python manage.py mimgrate

Step 7: Create a Superuser (Admin)

To access Django admin panel:

python manage.py createsuperuser

Enter:

  • Username

  • Email (optional)

  • Password


Step 8: Run the Development Server

Start the Django server:

python manage.py runserver

Open your browser and visit:

http://127.0.0.1:8000/

Admin panel:

http://127.0.0.1:8000/admin/

Your Django project is now running!


Step 9: Create a Django App

Create an app for your features (e.g., blog, users, core).

python manage.py startapp blog

Project structure now:

blog/
├── admin.py
├── apps.py
├── models.py
├── tests.py
├── views.py
└── migrations/

Step 10: Register App in Settings

Open config/settings.py and add your app:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'blog',
]

Step 11: Create Models and Migrate

After writing models in models.py:

python manage.py makemigrations
python manage.py migrate

Step 12: Freeze Dependencies (Best Practice)

Save installed packages:

pip freeze > requirements.txt

Later you can install them using:

pip install -r requirements.txt

Common Django Commands Cheat Sheet

python manage.py runserver
python manage.py startapp app_name
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py shell

Conclusion

Setting up a Django project is straightforward when you follow a structured approach. With virtual environments, clean project structure, and proper commands, you’re ready to build powerful web applications.