summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSwann <swann.bouviermuller@gmail.com>2022-01-06 15:34:31 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-06-03 20:01:16 +0200
commit9d8b694205f2617477faac0ba0edbd06c4d07605 (patch)
tree3a90c2db458dfc71b84eb5aca45f42d29ed4d3ed
parent566437adc9dd15dc18388bc256835a9448de0f6e (diff)
[4.1.x] Fixed documentation of Widget.id_for_label() empty return value.
Backport of d0863429a39dbc99a52a6d781006e7075c743d33 from main
-rw-r--r--django/forms/widgets.py4
-rw-r--r--docs/ref/forms/widgets.txt3
2 files changed, 4 insertions, 3 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index fffa7430fc..71f2710a2b 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -301,8 +301,8 @@ class Widget(metaclass=MediaDefiningClass):
def id_for_label(self, id_):
"""
- Return the HTML ID attribute of this Widget for use by a <label>,
- given the ID of the field. Return None if no ID is available.
+ Return the HTML ID attribute of this Widget for use by a <label>, given
+ the ID of the field. Return an empty string if no ID is available.
This hook is necessary because some widgets have multiple HTML
elements and, thus, multiple IDs. In that case, this method should
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index e0f175af79..168e92bd75 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -277,7 +277,8 @@ foundation for custom widgets.
.. method:: id_for_label(id_)
Returns the HTML ID attribute of this widget for use by a ``<label>``,
- given the ID of the field. Returns ``None`` if an ID isn't available.
+ given the ID of the field. Returns an empty string if an ID isn't
+ available.
This hook is necessary because some widgets have multiple HTML
elements and, thus, multiple IDs. In that case, this method should