summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeep Sukhwani <deepsukhwani@gmail.com>2020-03-28 18:52:54 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-03-31 10:46:48 +0200
commit4b146e0c83891fc67a422aa22f846bb7654c4d38 (patch)
tree379ab2bc958f952c95e22a139359dbc21faafc1e
parent93ed71e05802a47774b52503cdc3442686d686c1 (diff)
Fixed #30864 -- Doc'd classproperty decorator.
-rw-r--r--AUTHORS1
-rw-r--r--django/utils/functional.py4
-rw-r--r--docs/ref/utils.txt8
-rw-r--r--docs/releases/3.1.txt4
4 files changed, 15 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index 69a56718d8..371bfe070c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -246,6 +246,7 @@ answer newbie questions, and generally made Django that much better:
David Tulig <david.tulig@gmail.com>
David Wobrock <david.wobrock@gmail.com>
Davide Ceretti <dav.ceretti@gmail.com>
+ Deep L. Sukhwani <deepsukhwani@gmail.com>
Deepak Thukral <deep.thukral@gmail.com>
Denis Kuzmichyov <kuzmichyov@gmail.com>
Dennis Schwertel <dennisschwertel@gmail.com>
diff --git a/django/utils/functional.py b/django/utils/functional.py
index bc3b65b709..6d38f932f9 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -50,6 +50,10 @@ class cached_property:
class classproperty:
+ """
+ Decorator that converts a method with a single cls argument into a property
+ that can be accessed directly from the class.
+ """
def __init__(self, method=None):
self.fget = method
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 0375b2e63b..a9f4107d8c 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -556,6 +556,14 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
z = person.friends # does not call
x is z # is True
+.. class:: classproperty(method=None)
+
+ .. versionadded:: 3.1
+
+ Similar to :py:func:`@classmethod <classmethod>`, the ``@classproperty``
+ decorator converts the result of a method with a single ``cls`` argument
+ into a property that can be accessed directly from the class.
+
.. function:: keep_lazy(func, *resultclasses)
Django offers many utility functions (particularly in ``django.utils``)
diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt
index d133731c25..e4992b0a4a 100644
--- a/docs/releases/3.1.txt
+++ b/docs/releases/3.1.txt
@@ -557,8 +557,8 @@ Miscellaneous
``ETag`` header to responses with an empty
:attr:`~django.http.HttpResponse.content`.
-* ``django.utils.decorators.classproperty()`` decorator is moved to
- ``django.utils.functional.classproperty()``.
+* ``django.utils.decorators.classproperty()`` decorator is made public and
+ moved to :class:`django.utils.functional.classproperty()`.
* :tfilter:`floatformat` template filter now outputs (positive) ``0`` for
negative numbers which round to zero.