Django is an open-source, "batteries-included" Python web framework maintained by the Django Software Foundation. It's the #14 most-used web framework overall, reported in roughly 12.6% of developer surveys. Developers reach for it because it ships an ORM, an auto-generated admin panel, an authentication system, and a templating engine all built in โ making it the standard choice for building a full web app quickly in Python without assembling the pieces yourself.
A Django model class maps directly to a database table, and a urls.py route wires a URL pattern to a view function.
# models.py
from django.db import models
class Article(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
published = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
# urls.py
from django.urls import path
from . import views
urlpatterns = [
path("articles/<int:pk>/", views.article_detail, name="article_detail"),
]
Install Django, scaffold a new project, and create your first app inside it.
# install Django and start a project
pip install django
django-admin startproject mysite
cd mysite
# create an app and run the dev server
python manage.py startapp articles
python manage.py runserver