Back to stack index

Framework

Django

Python web framework for internal AI and search tools.

Short answer

Django is a Python web framework, free and open source under the BSD license, that includes an ORM, database migrations, an admin interface, authentication, forms and security protections out of the box. Many large open-source projects in our directory run on it: Khoj, a personal AI assistant; Paperless-ngx, a document manager with machine-learning tagging; Plane, a project tracker; Baserow, a no-code database; PostHog, a product analytics platform; and authentik, an identity provider. The latest version is Django 6.1.2. Django 6.0.8, released August 4, 2026, fixed a high-severity issue in spatial lookups along with other security problems. Django 6.2, the next long-term support release, is scheduled for April 2027. For AI work, Django's main strengths are that it is Python, so it sits next to model libraries and embedding code, and that it handles the unglamorous parts of an app, such as users, permissions, admin screens and data models, so teams can focus on AI features.

Latest version
Django 6.1.2
djangoproject.com/download
License
BSD
djangoproject.com
Next LTS
Django 6.2, April 2027
Django roadmap
Directory projects
Khoj, Paperless-ngx, Plane, Baserow, PostHog, authentik
Project repositories

Updated October 21, 2026How we evaluate tools

Official site

Directory projects (6)

  • Khoj

    Personal research assistant indexing notes, files, and web saves.

  • Paperless-ngx

    Paperless-ngx stores, shares, or signs documents with audit trails that stay in your tenant.

  • Plane

    Plane coordinates tasks and delivery boards for teams that want Jira-style tools without cloud lock-in.

  • Baserow

    Baserow combines chat, docs, or meetings in a workspace you deploy instead of a proprietary suite.

  • PostHog

    PostHog measures product usage with analytics data that never leaves servers you operate.

  • Authentik

    Authentik authenticates users with OIDC, SSO, or passkeys on identity servers you run.

Django for AI apps: how Khoj, Paperless-ngx, Plane, Baserow, PostHog and authentik use Python's web framework in 2026

What Django is

Django was created in 2003 at the Lawrence Journal-World newspaper in Kansas and released as open source in 2005. It follows a "batteries included" approach. A new Django project already has:

ComponentWhat it does
ORM and migrationsDefine models in Python; Django creates and changes tables
AdminA full data management interface generated from models
AuthUsers, groups, permissions, sessions and password hashing
Forms and validationServer-side input checking
Security defaultsProtection against CSRF, SQL injection, XSS and clickjacking
Async supportAsync views, middleware and ORM methods under ASGI

The Django Software Foundation, a non-profit, maintains it. Django REST Framework and Django Ninja are the common choices for building APIs on top.

Which directory projects use Django

ProjectWhat it isHow Django is used
KhojPersonal AI assistant that searches your notes and documentsDjango back end with FastAPI routes for the assistant
Paperless-ngxScans, OCRs and organizes documents with automatic taggingDjango app with Celery workers for OCR and classification
PlaneOpen-source project tracker, an alternative to Jira and LinearDjango REST API with a Next.js front end
BaserowNo-code database, an Airtable alternative with AI fieldsDjango back end with a Nuxt front end
PostHogProduct analytics, session replay, feature flags and moreDjango app with ClickHouse for event data
authentikIdentity provider with SSO, OAuth2, SAML and LDAPDjango core with Go outposts

These are large, long-lived codebases, which shows how Django scales when a team keeps its structure clean.

Recent releases and security

DateReleaseNotes
August 4, 20266.0.8Fixed a high-severity spatial lookup issue that could allow file writes or request forgery, plus moderate and low issues
20266.1.xCurrent feature release; 6.1.2 is the latest patch
April 20276.2 LTS (planned)Next long-term support release

The August fixes rejected unsafe values in GeoDjango spatial lookups, limited nesting depth in geometry collections and validated URLField links before rendering. If you use GeoDjango or accept user-supplied geometry, upgrade promptly. Django publishes security releases on a predictable schedule with pre-notification to registered users, and supports each feature release until shortly after the next one; LTS releases get security fixes for about three years.

Adding AI features to a Django app

Calling models

Put model calls in a service module rather than in views, so you can change providers, add retries and test with fakes. For requests users wait on, use async views and an async client, or stream the response. For slow or batch work such as summarizing uploaded documents, use a task queue.

Background jobs

OptionNotes
CeleryThe long-standing choice; used by Paperless-ngx and PostHog; needs Redis or RabbitMQ
Django's tasks frameworkBuilt-in background task interface added in Django 6.0, with pluggable backends
Dramatiq, Huey, RQLighter alternatives
Temporal or HatchetDurable workflows for long multi-step agent jobs

Redis is the most common broker; see the Redis stack page.

Retrieval and embeddings

With PostgreSQL and pgvector, add a VectorField to a model, generate embeddings in a background task when the record changes, and query with CosineDistance. Because vectors live in the same database as your other data, you can filter by owner, permissions and dates in one ORM query. For larger collections, a dedicated vector database such as Qdrant can sit alongside. See the PostgreSQL stack page.

Streaming responses

Under ASGI, an async view can return a StreamingHttpResponse that yields chunks from the model's stream as server-sent events. Run Django with Uvicorn, Daphne or Granian for async support, and make sure your reverse proxy does not buffer the response.

Admin as an AI back office

The Django admin is useful for AI apps: review flagged conversations, edit prompt templates stored in the database, inspect evaluation results and manage users' usage limits, all without building custom screens. Add custom admin actions such as "re-run classification" for selected records.

Example: an internal document assistant

A team building an internal Q&A tool on Django might use:

  1. A Document model with file uploads stored in S3-compatible storage.
  2. A Celery task that extracts text, splits it into chunks and stores embeddings in a Chunk model with a pgvector field.
  3. Django's permission system to record which teams may read each document.
  4. An async view that embeds the question, retrieves the top chunks the user may see, and streams an answer with citations.
  5. Admin screens to review low-rated answers and re-index documents.

Paperless-ngx follows a similar shape for document classification, and Khoj for personal search.

Django compared with other Python frameworks

FrameworkBest for
DjangoFull applications with database, auth and admin
FastAPIAsync APIs, model serving, microservices
FlaskSmall apps and prototypes with free choice of components
LitestarAsync APIs with more built-in structure than FastAPI
ReflexFull-stack apps written entirely in Python

Deployment

  • Run under Gunicorn for sync workloads or Uvicorn workers for async; use ASGI if you stream model output.
  • Serve static files with WhiteNoise or a CDN.
  • Use PostgreSQL in production, with connection pooling through PgBouncer or Django's built-in pooling for psycopg.
  • Run migrations as a separate deploy step.
  • Keep secrets, including model API keys, in environment variables or a secret manager, never in settings files committed to Git.
  • Containerize with Docker; see the Docker stack page.

Security tips for AI features

Model output is untrusted input. Escape it in templates, which Django does by default, and be careful with mark_safe or rendering Markdown to HTML; sanitize with a library such as nh3. Never pass model output into raw SQL, eval or shell commands. Rate-limit endpoints that call paid models per user, and log prompts and responses with retention limits that match your privacy policy.

Upgrading Django

Django deprecates features two releases before removing them, and prints deprecation warnings in the meantime. Run your test suite with warnings enabled (python -Wd manage.py test) before each upgrade, fix the warnings, then move one feature release at a time. Third-party packages are usually the slowest part; check that Django REST Framework, Celery integrations and any admin plugins support the target version before you start. Projects on LTS releases can jump from one LTS to the next, such as 5.2 to 6.2, but still benefit from testing against the intermediate releases.

Related: Python stack, FastAPI stack, PostgreSQL stack, Redis stack, PostHog stack, Ory stack, Stack index.

Frequently asked questions

Is Django good for AI apps?

Yes, especially when the app needs users, permissions, an admin interface and a relational data model alongside AI features. Because it is Python, it can import model SDKs, LangChain, LlamaIndex or local model libraries directly. For a small API that only wraps a model, FastAPI is lighter.

Can Django stream model responses?

Yes. StreamingHttpResponse can send tokens as they arrive, and under ASGI with an async view it streams without tying up a worker thread. Django Channels adds WebSockets for two-way real-time features.

Should I use Django or FastAPI?

Django for full applications with a database, admin, auth and server-rendered pages or a large API. FastAPI for focused, async-first APIs and model-serving endpoints. Many teams use both: Django for the main app and FastAPI for an inference or retrieval service.

Which Django version should I use?

New projects can use Django 6.1. Projects that prefer fewer upgrades should stay on the current long-term support release, Django 5.2, until Django 6.2 LTS arrives in April 2027. Always apply security patch releases promptly.

How do I store embeddings in Django?

Use PostgreSQL with the pgvector extension and the pgvector-python package, which adds a VectorField and distance functions to the Django ORM. You can then filter by regular fields and sort by vector similarity in one query.

Sources

  1. Django downloads
  2. Django security releases
  3. Django release roadmap
  4. pgvector-python