[Django] #33166: Missing context when rendering form widgets

53 views
Skip to first unread message

Django

unread,
Oct 3, 2021, 6:02:16 PM10/3/21
to django-...@googlegroups.com
#33166: Missing context when rendering form widgets
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: nobody
Rief |
Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: 4.0
Severity: Normal | Keywords: form, widget,
Triage Stage: | context
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Unsure if this shall be a feature request, but I noticed that when
rendering a field label, the template's rendering context additionally
contains the `field`- and the `form`-object. If however, I render the
widget itself, this information is not available inside the widget's
template rendering context. Apart from this inconsistency, being able to
access the `field`- and/or the `form`-object, when rendering a widget is
really useful.

Example:
I would like to use the `form`-attribute inside some `<input …>`-widgets,
so that each field can refer to its corresponding form. See
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-form
for details. The `form`-object itself provides a name, which is used as
the `<form id="…" …>`. Therefore each widget has to know their form's
name. This information currently can not be determined inside the widget's
template.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 4, 2021, 4:00:57 AM10/4/21
to django-...@googlegroups.com
#33166: Missing context when rendering form widgets
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: 4.0
Severity: Normal | Resolution:

Keywords: form, widget, | Triage Stage:
context | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

Note that `form` is no longer in the context after #33134.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:1>

Django

unread,
Oct 4, 2021, 5:44:34 AM10/4/21
to django-...@googlegroups.com
#33166: Missing context when rendering form widgets
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: 4.0
Severity: Normal | Resolution:

Keywords: form, widget, | Triage Stage:
context | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jacob Rief):

Well, in case of the label rendering context, the `form`-object is
accessible through the `field`. However, the widget rendering context
doesn't offer the `field`-object.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:2>

Django

unread,
Oct 6, 2021, 6:17:17 AM10/6/21
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.

-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 4.0
Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: David Smith (added)
* type: Cleanup/optimization => New feature
* stage: Unreviewed => Accepted


Comment:

Tentatively accepted, this will require passing `field` to the
`Widget.render()`.

This is not strictly related with
456466d932830b096d39806e291fe23ec5ed38d5.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:3>

Django

unread,
Oct 7, 2021, 7:25:46 PM10/7/21
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0
Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Rief):

* owner: nobody => Jacob Rief
* status: new => assigned
* has_patch: 0 => 1


Comment:

Here is a draft pull request to implement this:
https://github.com/django/django/pull/14955

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:4>

Django

unread,
Oct 8, 2021, 12:30:44 AM10/8/21
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:5>

Django

unread,
Oct 9, 2021, 10:46:15 AM10/9/21
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by David Smith):

I wonder about creating a circular context here. A field has a widget and
you can access the field from the context of the widget and so on. See
#33134 for a recent bug with field labels.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:6>

Django

unread,
Feb 23, 2023, 2:51:38 AM2/23/23
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0


Comment:

This should be review again.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:7>

Django

unread,
Feb 23, 2023, 2:56:51 AM2/23/23
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Sarah Boyce (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:8>

Django

unread,
Feb 28, 2023, 2:35:01 AM2/28/23
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

As per David's comment on the PR here, we should resolve #34077 first, to
see if that gives everything needed here.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:9>

Django

unread,
Mar 16, 2023, 7:36:49 AM3/16/23
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


Comment:

Marking as "Patch needs improvement" as this is waiting for #34077.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:10>

Django

unread,
May 19, 2023, 4:25:39 AM5/19/23
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: assigned
Component: Forms | Version: 4.0

Severity: Normal | Resolution:
Keywords: form, widget, | Triage Stage: Accepted
context |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Jacob, Have you seen cad376f844c7bdeeee7607a7c0ea8ae52061309b? Do we still
need this change?

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:11>

Django

unread,
Nov 17, 2023, 2:35:59 PM11/17/23
to django-...@googlegroups.com
#33166: Add "field" to the context when rendering widgets.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Jacob
| Rief
Type: New feature | Status: closed
Component: Forms | Version: 4.0
Severity: Normal | Resolution: wontfix

Keywords: form, widget, | Triage Stage:
context | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed


* needs_better_patch: 1 => 0

* has_patch: 1 => 0
* resolution: => wontfix
* stage: Accepted => Unreviewed


Comment:

I think it's no longer needed after
cad376f844c7bdeeee7607a7c0ea8ae52061309b.

--
Ticket URL: <https://code.djangoproject.com/ticket/33166#comment:12>

Reply all
Reply to author
Forward
0 new messages