diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index e29f9a3e830..5c6701aef2d 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -436,7 +436,7 @@ def simplify_regex(pattern): pattern = replace_named_groups(pattern) pattern = replace_unnamed_groups(pattern) # clean up any outstanding regex-y characters. - pattern = pattern.replace('^', '').replace('$', '') + pattern = pattern.replace('^', '').replace('$', '').replace('?', '') if not pattern.startswith('/'): pattern = '/' + pattern return pattern diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py index b48147fc852..bd483007c75 100644 --- a/tests/admin_docs/test_views.py +++ b/tests/admin_docs/test_views.py @@ -340,6 +340,7 @@ class AdminDocViewFunctionsTests(SimpleTestCase): (r'^(?P(x|y))/b/(?P\w+)$', '//b/'), (r'^(?P(x|y))/b/(?P\w+)ab', '//b/ab'), (r'^(?P(x|y)(\(|\)))/b/(?P\w+)ab', '//b/ab'), + (r'^a/?$', '/a/'), ) for pattern, output in tests: self.assertEqual(simplify_regex(pattern), output)