[Django] #32917: Add an internal _value_from_datadict() method to BaseForm

8 views
Skip to first unread message

Django

unread,
Jul 11, 2021, 3:19:16 PM7/11/21
to django-...@googlegroups.com
#32917: Add an internal _value_from_datadict() method to BaseForm
-------------------------------------+-------------------------------------
Reporter: Chris | Owner: Chris Jerdonek
Jerdonek |
Type: | Status: assigned
Cleanup/optimization |
Component: Forms | Version: dev
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
I noticed that some call sites can be simplified if an internal method
called something like `_value_from_datadict()` is added to `BaseForm`.
Here is one of the call sites:
https://github.com/django/django/blob/6f60fa97b0b501ef7cc77e16392654bf27ec8db3/django/forms/boundfield.py#L121

Its implementation can look something like this:

{{{#!python
def _value_from_datadict(self, field, html_name):
return field.widget.value_from_datadict(self.data, self.files,
html_name)
}}}

One reason this is nicer is that callers don't have to know about the
form's `self.data` and `self.files` dicts. They can just access a method
on the form, which encapsulates the data dictionaries.

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

Django

unread,
Jul 12, 2021, 12:52:21 AM7/12/21
to django-...@googlegroups.com
#32917: Add an internal _value_from_datadict() method to BaseForm
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


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

Django

unread,
Jul 12, 2021, 2:38:40 PM7/12/21
to django-...@googlegroups.com
#32917: Add an internal _value_from_datadict() method to BaseForm
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Forms | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Jerdonek):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/14629

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

Django

unread,
Jul 13, 2021, 12:32:59 AM7/13/21
to django-...@googlegroups.com
#32917: Add an internal _value_from_datadict() method to BaseForm
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"4be58fcc369a024bd7ac72bb09af7d230499cccb" 4be58fc]:
{{{
#!CommitTicketReference repository=""
revision="4be58fcc369a024bd7ac72bb09af7d230499cccb"
Fixed #32917 -- Added BaseForm._widget_data_value()/_field_data_value().
}}}

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

Reply all
Reply to author
Forward
0 new messages