diff --git a/django/utils/inspect.py b/django/utils/inspect.py index 81a15ed2db..4e065f0347 100644 --- a/django/utils/inspect.py +++ b/django/utils/inspect.py @@ -68,9 +68,7 @@ def func_accepts_var_args(func): def method_has_no_args(meth): """Return True if a method only accepts 'self'.""" - count = len( - [p for p in _get_callable_parameters(meth) if p.kind == p.POSITIONAL_OR_KEYWORD] - ) + count = len([p for p in _get_callable_parameters(meth) if p.kind in ARG_KINDS]) return count == 0 if inspect.ismethod(meth) else count == 1 diff --git a/tests/admin_docs/models.py b/tests/admin_docs/models.py index a403259c6d..b4ef84caba 100644 --- a/tests/admin_docs/models.py +++ b/tests/admin_docs/models.py @@ -54,6 +54,12 @@ class Person(models.Model): def dummy_function(self, baz, rox, *some_args, **some_kwargs): return some_kwargs + def dummy_function_keyword_only_arg(self, *, keyword_only_arg): + return keyword_only_arg + + def all_kinds_arg_function(self, position_only_arg, /, arg, *, kwarg): + return position_only_arg, arg, kwarg + @property def a_property(self): return "a_property" diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py index ef7fde1bf9..064ce27fb0 100644 --- a/tests/admin_docs/test_views.py +++ b/tests/admin_docs/test_views.py @@ -280,6 +280,8 @@ class TestModelDetailView(TestDataMixin, AdminDocsTestCase): self.assertContains(self.response, "