From 4a3e78e05fda3c5aeb042f9f901ad90b79fdb508 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 20 Jan 2026 16:42:39 -0500 Subject: [PATCH] build: Don't try to read the database when building docs. Sphinx tries to explore all the defined objects when trying to generate docs from the code. When it tries to introspect the QuerySet object, it results in that object trying to query the database which we don't really want to setup for a docs build as it's not relevant and fairly expensive to do. To circumvent this issue, we add a new filter to the docs build that essentially skips further introspection of QuerySet objects. --- docs/conf.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 71ce84a33e..297f508cde 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,6 +13,7 @@ from subprocess import check_call import django import git +from django.db.models.query import QuerySet from path import Path @@ -379,7 +380,14 @@ def on_init(app): # lint-amnesty, pylint: disable=redefined-outer-name, unused- check_call(args) +def skip_querysets(app, what, name, obj, skip, options): + # If the object is a Django QuerySet, skip it + if isinstance(obj, QuerySet): + return True + return skip + + def setup(app): # lint-amnesty, pylint: disable=redefined-outer-name """Sphinx extension: run sphinx-apidoc.""" - event = 'builder-inited' - app.connect(event, on_init) + app.connect('builder-inited', on_init) + app.connect('autodoc-skip-member', skip_querysets)