Last Updated : 12 Jul, 2025
Django is a Python-based web framework which allows us to quickly develop robust web application without much third party installations. It comes with many built-in features—like user authentication, an admin panel and form handling—that help you build complex sites without worrying about common web development tasks.
Key Features of DjangoDjango Architecture: The MVT PatternFor more insight on when to use Django, check out: When to Use Django? Comparison with other Development Stacks ?
Django is based on MVT (Model-View-Template) architecture. MVT is a software design pattern for developing a web application. It's structure has the following three parts :
1. Model: Acts as the data interface. It defines the structure of your data and is usually backed by a database (e.g., MySQL, PostgreSQL).
2. View: A Python function or class that handles web requests. It interacts with the Model and renders a response, typically by passing data to a Template.
3. Template: Contains static HTML mixed with Django’s templating syntax. Templates are used to display dynamic data on the web page.
Django MVTInstalling DjangoTo check more about Django's architecture, visit Django Project MVT Structure
Follow these steps to set up Django on your system:
1. Install Python 3:Download and install the latest Python 3 version from the official website.
2. Install pip:Pip comes with recent versions of Python. Open the command prompt and run:
3. Set Up a Virtual Environment:pip --version
This isolates your project’s dependencies.
4. Activate the Environment:python -m virtualenv env_site
Windows:
cd env_site\Scripts\activate
Mac/Linux:
5. Install Django:source env_site/bin/activate
With your virtual environment active, run:
Create a Django Project and App 1. Create a Django Projectpip install django
Open the terminal and run:
django-admin startproject projectName
cd projectName
This creates a new folder named projectName containing your project settings and then changes the current working directory to it..
2. Create a Django AppInside the project directory (where manage.py is located), run:
python manage.py startapp projectApp
This creates a new app named projectApp.
Now you can see your directory structure as under :
3. Update INSTALLED_APPS in SettingsIn projectName/settings.py, add your app to the INSTALLED_APPS list:
Python
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'projectApp'
]
We have finally created an app but to render it using urls we need to include the app in our main project so that urls redirected to that app can be rendered.
4. Include App URLs in the Main ProjectEdit projectName/urls.py to include your app’s URLs:
Python
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("projectApp.urls")), # Routes all other URLs to projectApp
]
Make sure you create a urls.py file inside projectApp to define your app’s routes.
Using Django’s MVT ModelOnce your project is set up:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4