Skip to main content

Generate llms.txt files for Django websites. Make your content discoverable by AI assistants.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_llms_txt-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_llms_txt-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file django_llms_txt-0.1.0.tar.gz.

File metadata

  • Download URL: django_llms_txt-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for django_llms_txt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f8fa8bb84347ecdf88c989bb3380cdddc1e09d7cf1956c7c8cb41e7ef3c71f81
MD5 af1992f5378af5a93b69abfa911afbfe
BLAKE2b-256 fef688917bf99f48eeb41c9067b43f703b4cbf355b03eb2caf2e205f17d05399

See more details on using hashes here.

File details

Details for the file django_llms_txt-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_llms_txt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 331bfcad5bc70667c21a1b898a3d69a7b52074056f309d86791b5913f5d12b02
MD5 82b1599ab7b042c341ec88b77f630884
BLAKE2b-256 efa2b385ec65b7ce7221d23b073c9219bb67d975e8e119009af40bf097e64668

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page