[Django] #36753: Django docs GitHub source links use incorrect line numbers for version branches

11 views
Skip to first unread message

Django

unread,
Nov 23, 2025, 12:26:18 PM (7 days ago) Nov 23
to django-...@googlegroups.com
#36753: Django docs GitHub source links use incorrect line numbers for version
branches
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Type: Bug
Status: new | Component:
| Documentation
Version: dev | Severity: Normal
Keywords: documentation, | Triage Stage:
function link | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Django documentation uses Sphinx's `.. function::` directive to generate
source code links.
while these links correctly point to version-specific branches (e.g.,
`stable/5.2.x`),
the line numbers are calculated from the `main` branch, not the documented
version.

== reproduce:
1. visit Django 5.2 documentation:
https://docs.djangoproject.com/en/5.2/ref/models/instances/#django.db.models.Model
2. click the "**[source]"** link
3. note the line number in the URL

== current behavior:
the source link might be:
(https://github.com/django/django/blob/stable/5.2.x/django/db/models/base.py#L498)

but in the stable/5.2.x branch, the function is actually at line **461**,
not **498**.

== expect behavior:
line number should match the actual location in the version-specific
branch (e.g., L461 for stable/5.2.x).

the issue appears to be related to how line numbers are calculated during
the documentation build process.
relevant code is in
https://github.com/django/django/blob/main/docs/_ext/github_links.py#L78:
the links still work, but the inaccurate line numbers can be confusing.
--
Ticket URL: <https://code.djangoproject.com/ticket/36753>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 23, 2025, 8:48:57 PM (6 days ago) Nov 23
to django-...@googlegroups.com
#36753: Django docs GitHub source links use incorrect line numbers for version
branches
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner: entuziaz
Type: Bug | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage:
function link | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by entuziaz):

* owner: (none) => entuziaz
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36753#comment:1>

Django

unread,
Nov 23, 2025, 10:59:14 PM (6 days ago) Nov 23
to django-...@googlegroups.com
#36753: Django docs GitHub source links use incorrect line numbers for version
branches
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner: entuziaz
Type: Bug | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage:
function link | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by entuziaz):

I’ve opened a PR for this: [https://github.com/django/django/pull/20307].
Tests and docs build pass locally.
--
Ticket URL: <https://code.djangoproject.com/ticket/36753#comment:2>

Django

unread,
Nov 25, 2025, 5:11:20 PM (5 days ago) Nov 25
to django-...@googlegroups.com
#36753: Django docs GitHub source links use incorrect line numbers for version
branches
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner:
| JekayinOluwa Olabemiwo
Type: Bug | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage: Accepted
function link |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36753#comment:3>

Django

unread,
Nov 26, 2025, 10:27:57 AM (4 days ago) Nov 26
to django-...@googlegroups.com
#36753: Django docs GitHub source links use incorrect line numbers for version
branches
-------------------------------------+-------------------------------------
Reporter: Youngkwang Yang | Owner:
| JekayinOluwa Olabemiwo
Type: Bug | Status: closed
Component: Documentation | Version: dev
Severity: Normal | Resolution: duplicate
Keywords: documentation, | Triage Stage: Accepted
function link |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Smith):

* resolution: => duplicate
* status: assigned => closed

Comment:

This appears to be a duplicate of #36450

Looking at this again I still think this is an issue at djangoproject.com
(1) as the links generated at readthedocs are correct (2).

(1) https://github.com/django/djangoproject.com/issues/2091
(2) https://django.readthedocs.io/en/5.2.x/ref/models/instances.html
--
Ticket URL: <https://code.djangoproject.com/ticket/36753#comment:4>
Reply all
Reply to author
Forward
0 new messages