Skip to main content

django-llms-txt

Generate llms.txt files for your Django website. Make your content discoverable by AI assistants like ChatGPT, Claude, and Perplexity.

PyPI version License: MIT Django versions

What is llms.txt?

llms.txt is an open standard that helps Large Language Models understand your website's content. By providing a structured text file at /llms.txt, you make it easy for AI assistants to discover and reference your pages accurately.

Features

  • Settings-based configuration — define sections and links in your Django settings
  • Auto-generate from models — automatically build sections from your Django models (blog posts, docs, products, etc.)
  • Dynamic serving — serve llms.txt and llms-full.txt as Django views
  • Static generation — generate static files via management command
  • Full text support — optionally serve expanded content via llms-full.txt

Installation

pip install django-llms-txt

Add to your INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "django_llms_txt",
]

Quick Start

1. Configure in settings.py

LLMS_TXT = {
    "SITE_NAME": "My Django Project",
    "SITE_URL": "https://example.com",
    "DESCRIPTION": "A brief description of your website.",
    "SECTIONS": [
        {
            "title": "Documentation",
            "links": [
                {
                    "name": "Getting Started",
                    "url": "/docs/start/",
                    "description": "Quick start guide",
                },
                {
                    "name": "API Reference",
                    "url": "/docs/api/",
                    "description": "Complete API documentation",
                },
            ],
        },
    ],
}

2. Add URL patterns

# urls.py
from django_llms_txt.urls import urlpatterns as llms_patterns

urlpatterns = [
    # ... your URLs
] + llms_patterns

This adds /llms.txt and /llms-full.txt to your site.

3. Visit your llms.txt

Navigate to https://yoursite.com/llms.txt and you'll see:

# My Django Project

> A brief description of your website.

## Documentation

- [Getting Started](https://example.com/docs/start/): Quick start guide
- [API Reference](https://example.com/docs/api/): Complete API documentation

Auto-Generate from Models

The real power of django-llms-txt is auto-generating sections from your Django models:

LLMS_TXT = {
    "SITE_NAME": "My Blog",
    "SITE_URL": "https://example.com",
    "DESCRIPTION": "A blog about Django development.",
    "AUTO_SECTIONS": [
        {
            "title": "Blog Posts",
            "model": "blog.Post",
            "filter": {"status": "published"},
            "ordering": ["-published_date"],
            "name_field": "title",
            "url_method": "get_absolute_url",
            "description_field": "excerpt",
            "full_text_field": "content",
            "limit": 50,
        },
        {
            "title": "Categories",
            "model": "blog.Category",
            "name_field": "name",
            "url_method": "get_absolute_url",
            "description_field": "description",
        },
    ],
    "FULL_TEXT": True,
}

AUTO_SECTIONS Options

Option Required Description
title Yes Section heading
model Yes Django model path (e.g., "blog.Post")
filter No QuerySet filter dict (e.g., {"status": "published"})
ordering No QuerySet ordering (string or list)
name_field No Model field for link text (default: "title")
url_method No Method/attribute for URL (default: "get_absolute_url")
description_field No Model field for link description
full_text_field No Model field for full content (used in llms-full.txt)
limit No Maximum number of entries

Management Command

Generate static files instead of serving dynamically:

# Generate in current directory
python manage.py generate_llms_txt

# Generate in a specific directory
python manage.py generate_llms_txt --output static/

Set FULL_TEXT: True in your config to also generate llms-full.txt.

Configuration Reference

LLMS_TXT = {
    # Required
    "SITE_NAME": "My Site",
    "SITE_URL": "https://example.com",

    # Optional
    "DESCRIPTION": "A brief description.",
    "SECTIONS": [...],         # Static sections
    "AUTO_SECTIONS": [...],    # Model-based sections
    "FULL_TEXT": False,        # Enable llms-full.txt
    "EXCLUDE_PATTERNS": [],    # URL patterns to exclude
}

Combining Static and Auto Sections

You can mix both approaches:

LLMS_TXT = {
    "SITE_NAME": "My Site",
    "SITE_URL": "https://example.com",
    "DESCRIPTION": "Description here.",
    "SECTIONS": [
        {
            "title": "About",
            "links": [
                {"name": "About Us", "url": "/about/"},
                {"name": "Contact", "url": "/contact/"},
            ],
        },
    ],
    "AUTO_SECTIONS": [
        {
            "title": "Blog",
            "model": "blog.Post",
            "filter": {"status": "published"},
            "name_field": "title",
            "url_method": "get_absolute_url",
            "description_field": "excerpt",
        },
    ],
}

Requirements

  • Python 3.9+
  • Django 4.2+

Created by

Built by Rapitek - Enterprise CRM platform with 10+ years of industry experience. We use django-llms-txt in production to power our own llms.txt.

License

MIT License. See LICENSE for details.

Metadata

Release files for django-llms-txt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-llms-txt 0.1.0
File Size Uploaded
django_llms_txt-0.1.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-llms-txt 0.1.0
File Interpreter ABI Platform
django_llms_txt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / django_llms_txt-0.1.0.tar.gz

Download URL django_llms_txt-0.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f8fa8bb84347ecdf88c989bb3380cdddc1e09d7cf1956c7c8cb41e7ef3c71f81
BLAKE2b-256 checksum
How to use checksums
fef688917bf99f48eeb41c9067b43f703b4cbf355b03eb2caf2e205f17d05399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / django_llms_txt-0.1.0-py3-none-any.whl

Download URL django_llms_txt-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
331bfcad5bc70667c21a1b898a3d69a7b52074056f309d86791b5913f5d12b02
BLAKE2b-256 checksum
How to use checksums
efa2b385ec65b7ce7221d23b073c9219bb67d975e8e119009af40bf097e64668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page