Table of Contents


Django Intro

Django is a high-level Python web framework for building secure and scalable web applications quickly. It uses the Model-View-Template (MVT) pattern, provides an ORM for database access, an automatic admin panel, and built-in authentication. With its “Don’t Repeat Yourself” philosophy and strong community support, Django makes developing modern web apps faster and more maintainable.

Project Structure

A Django project is considered a project. And under this project, it has many apps. For example, you want to build a social media app, and this app has many features: comments, follow, share, etc. In this example, the social media app is considered a project, and each different feature is considered a different app.

A project structure can be like this:

myproject/                  <-- project root folder
│
├── manage.py               <-- command-line utility to run/maintain project
│
├── myproject/              <-- inner project folder (same name as root)
│   ├── __init__.py         <-- marks as a Python package
│   ├── settings.py         <-- main configuration: DB, installed apps, etc.
│   ├── urls.py             <-- URL routing (maps URLs to views)
│   ├── asgi.py             <-- entry point for async servers (Daphne, Uvicorn)
│   └── wsgi.py             <-- entry point for WSGI servers (Gunicorn, etc.)
│
└── venv/                   <-- (optional) your virtual environment

Key Difference

Example:

If you’re making an E-commerce website:

Set Up

Virtual Environment

Django recommends running on a Python virtual environment. Here is how to set up: