Django is a high-level Python Web Framework used to build secure, scalable and maintainable web applications.
Django follows the "Don't Repeat Yourself (DRY)" principle and provides many built-in features that reduce development time.
A Virtual Environment is an isolated Python environment used to install project-specific packages.
It helps avoid conflicts between packages used by different projects.
mkdir DjangoTraining
cd DjangoTraining
python -m venv env
env\Scripts\activate
(env) C:\DjangoTraining>
deactivate
After activating the Virtual Environment, we can install Django using pip.
pip install django
django-admin --version
6.0.6
pip list
Package Version
--------- -------
Django 6.0.6
pip 26.1.2
sqlparse 0.5.5
asgiref 3.11.1
A Django Project is the main container that holds settings, URLs and applications.
django-admin startproject BlogProject
cd BlogProject
python manage.py runserver
Starting development server at
http://127.0.0.1:8000/
http://127.0.0.1:8000
If installation and project creation are successful, Django displays its default welcome page.
CTRL + C
python -m venv env
env\Scripts\activate
pip install django
django-admin startproject BlogProject
cd BlogProject
python manage.py runserver
A Django Application is a module that performs a specific task within a project.
python manage.py startapp blog
BlogProject
│
├── BlogProject
│
├── blog
│
└── manage.py
After creating an application, we must register it in the project's settings.py file.
If the application is not registered, Django will not be able to use its templates, models, admin configuration and other resources.
trainingproject/settings.py
INSTALLED_APPS = [
'demo',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
After creating a project and application, Django generates several files and folders automatically.
BlogProject
│
├── BlogProject
│ ├── settings.py
│ ├── urls.py
│ ├── asgi.py
│ ├── wsgi.py
│ └── __init__.py
│
├── blog
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── tests.py
│ ├── views.py
│ └── migrations
│
└── manage.py
| File | Purpose |
|---|---|
| manage.py | Execute Django Commands |
| settings.py | Project Configuration |
| urls.py | URL Routing |
| views.py | Application Logic |
| models.py | Database Models |
| admin.py | Admin Panel Configuration |