diff --git a/AUTHORS b/AUTHORS
index 4e91d7b3f30..2cddbf9280b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -808,6 +808,7 @@ answer newbie questions, and generally made Django that much better:
Radek Švarz
Rafael Giebisch
Raffaele Salmaso
+ Rahmat Faisal
Rajesh Dhawan
Ramez Ashraf
Ramil Yanbulatov
diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
index 6edff502ecd..3708a32813f 100644
--- a/django/contrib/admindocs/utils.py
+++ b/django/contrib/admindocs/utils.py
@@ -101,6 +101,9 @@ ROLES = {
def create_reference_role(rolename, urlbase):
+ # Views and template names are case-sensitive.
+ is_case_sensitive = rolename in ["template", "view"]
+
def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None:
options = {}
@@ -111,7 +114,7 @@ def create_reference_role(rolename, urlbase):
urlbase
% (
inliner.document.settings.link_base,
- text.lower(),
+ text if is_case_sensitive else text.lower(),
)
),
**options,
diff --git a/tests/admin_docs/test_utils.py b/tests/admin_docs/test_utils.py
index 18c6769fade..81528572635 100644
--- a/tests/admin_docs/test_utils.py
+++ b/tests/admin_docs/test_utils.py
@@ -104,6 +104,22 @@ class TestUtils(AdminDocsSimpleTestCase):
self.assertEqual(parse_rst(body, ""), "second line
\n")
self.assertEqual(stderr.getvalue(), "")
+ def test_parse_rst_view_case_sensitive(self):
+ source = ":view:`myapp.views.Index`"
+ rendered = (
+ 'myapp.views.Index
'
+ )
+ self.assertHTMLEqual(parse_rst(source, "view"), rendered)
+
+ def test_parse_rst_template_case_sensitive(self):
+ source = ":template:`Index.html`"
+ rendered = (
+ ''
+ "Index.html
"
+ )
+ self.assertHTMLEqual(parse_rst(source, "template"), rendered)
+
def test_publish_parts(self):
"""
Django shouldn't break the default role for interpreted text