Description #
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It comes with built-in features for user authentication, admin panels, database models, and URL routing, making it ideal for building scalable, secure web applications fast.
History #
Django was created in 2003 by Adrian Holovaty and Simon Willison while working at a newspaper, the Lawrence Journal-World, to build content-heavy sites quickly. It was open-sourced in 2005 and named after jazz guitarist Django Reinhardt.
Key milestones:
- 2005: Django 1.0 released with full admin, ORM, and templating system
- 2017: Django 2.0 drops Python 2 support
- 2020+: Django 3+ and 4+ embrace async views and modern features
- Used by large platforms like Instagram, Pinterest, Mozilla, and Disqus
Hello World Code #
# hello/views.py
from django.http import HttpResponse
def hello_world(request):
return HttpResponse("Hello, World!")
# hello/urls.py
from django.urls import path
from .views import hello_world
urlpatterns = [
path('', hello_world),
]
How to Run #
Locally: #
- Install Django:
pip install django
- Create project and app:
django-admin startproject mysite
cd mysite
python manage.py startapp hello
- Add your view and URL pattern (as shown above)
- Include
hello.urls
in the mainmysite/urls.py
- Run the server:
python manage.py runserver
Visit http://127.0.0.1:8000/
to see “Hello, World!”
Key Concepts #
- MTV architecture — Model, Template, View (similar to MVC)
- ORM — interact with databases using Python classes
- Admin panel — auto-generated backend for managing content
- URL routing — maps URLs to views cleanly
- Templates — HTML with dynamic tags using the Django template language
- Forms & Validation — built-in tools for handling user input
- Middleware — process requests/responses globally
- Authentication system — user login, logout, and permissions
- Security features — CSRF protection, XSS prevention, HTTPS support
- Asynchronous support — added in Django 3.1+ for performance
Try It Online #
🔗 Replit – Django Template
🔗 PythonAnywhere – Django Web App
🔗 Django Girls Tutorial
Fun Facts #
- Named after Django Reinhardt, a Belgian jazz guitarist
- Built originally for online journalism, now used by startups and enterprise apps
- The admin dashboard is one of Django’s standout features
- Emphasizes “Don’t Repeat Yourself” (DRY) principles
- Many popular platforms began as Django MVPs, including Instagram