[Django] #24347: parameter 'widget' of BoundField.as_widget is ignored

23 views
Skip to first unread message

Django

unread,
Feb 16, 2015, 9:20:23 AM2/16/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
----------------------------+-----------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
Severity: Normal | Keywords: BoundField, as_widget
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 1
----------------------------+-----------------------------------
'as_widget' has the parameter 'widget' which renders the field. However,
this parameter is not used all the time during the 'as_widget' call.

The method 'data', which is called by 'as_widget' ALWAYS used the default
widget of the field which leads to issues.

We recognized this issue when using 'show_hidden_initial=True' and widgets
for datetime objects.

The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

cf.
as_widget:
https://github.com/django/django/blob/master/django/forms/forms.py#L526
data:
https://github.com/django/django/blob/master/django/forms/forms.py#L569
as_hidden:
https://github.com/django/django/blob/master/django/forms/forms.py#L562

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

Django

unread,
Feb 16, 2015, 9:21:30 AM2/16/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by srkunze):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

> 'as_widget' has the parameter 'widget' which renders the field. However,
> this parameter is not used all the time during the 'as_widget' call.
>
> The method 'data', which is called by 'as_widget' ALWAYS used the default
> widget of the field which leads to issues.
>
> We recognized this issue when using 'show_hidden_initial=True' and
> widgets for datetime objects.
>
> The problem can also be observed when using BoundField.as_hidden as it
> uses 'as_widget' as well.
>
> cf.
> as_widget:
> https://github.com/django/django/blob/master/django/forms/forms.py#L526
> data:
> https://github.com/django/django/blob/master/django/forms/forms.py#L569
> as_hidden:
> https://github.com/django/django/blob/master/django/forms/forms.py#L562

New description:

'as_widget' has the parameter 'widget' which renders the field. However,
this parameter is not used all the time during the 'as_widget' call.

The method 'data', which is called by 'as_widget' ALWAYS used the default

widget of the field which leads to issues like formatting etc.

We recognized this issue when using 'show_hidden_initial=True' and widgets
for datetime objects.

The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

--

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

Django

unread,
Feb 16, 2015, 9:23:25 AM2/16/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by srkunze:

Old description:

> 'as_widget' has the parameter 'widget' which renders the field. However,
> this parameter is not used all the time during the 'as_widget' call.
>
> The method 'data', which is called by 'as_widget' ALWAYS used the default

> widget of the field which leads to issues like formatting etc.


>
> We recognized this issue when using 'show_hidden_initial=True' and
> widgets for datetime objects.
>
> The problem can also be observed when using BoundField.as_hidden as it
> uses 'as_widget' as well.
>
> cf.
> as_widget:
> https://github.com/django/django/blob/master/django/forms/forms.py#L526
> data:
> https://github.com/django/django/blob/master/django/forms/forms.py#L569
> as_hidden:
> https://github.com/django/django/blob/master/django/forms/forms.py#L562

New description:

'as_widget' has the parameter 'widget' which renders the field. However,
this parameter is not used all the time during the 'as_widget' call.

The method 'data', which is (indirectly via 'value') called by 'as_widget'
ALWAYS used the default widget of the field which leads to issues like
formatting etc.

We recognized this issue when using 'show_hidden_initial=True' and widgets
for datetime objects.

The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

--

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

Django

unread,
Feb 16, 2015, 12:33:49 PM2/16/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8alpha1

Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by srkunze):

* version: master => 1.8alpha1
* needs_tests: 0 => 1


Old description:

> 'as_widget' has the parameter 'widget' which renders the field. However,
> this parameter is not used all the time during the 'as_widget' call.
>

> The method 'data', which is (indirectly via 'value') called by


> 'as_widget' ALWAYS used the default widget of the field which leads to

> issues like formatting etc.


>
> We recognized this issue when using 'show_hidden_initial=True' and
> widgets for datetime objects.
>
> The problem can also be observed when using BoundField.as_hidden as it
> uses 'as_widget' as well.
>
> cf.
> as_widget:
> https://github.com/django/django/blob/master/django/forms/forms.py#L526
> data:
> https://github.com/django/django/blob/master/django/forms/forms.py#L569
> as_hidden:
> https://github.com/django/django/blob/master/django/forms/forms.py#L562

New description:

'as_widget' has the parameter 'widget' which renders the field. However,
this parameter is not used all the time during the 'as_widget' call.

The method 'data', which is (indirectly via 'value') called by 'as_widget'
ALWAYS used the default widget of the field which leads to issues like
formatting etc.

We recognized this issue when using 'show_hidden_initial=True' and widgets
for datetime objects.

The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

Versions: 1.4, 1.5, 1.6, 1.7, 1.8, master

--

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

Django

unread,
Feb 16, 2015, 2:09:02 PM2/16/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution: needsinfo

Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* resolution: => needsinfo


Comment:

Replying to [ticket:24347 srkunze]:


> 'as_widget' has the parameter 'widget' which renders the field. However,
this parameter is not used all the time during the 'as_widget' call.

Sorry, but that's not true. The widget parameter is used in
`widget.render(...)` at the end of the method. It's totally possible
something is not working properly, but then we'll need a more thorough
example to demonstrate the issue.

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

Django

unread,
Feb 17, 2015, 8:35:52 AM2/17/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: Bug | Status: closed
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution: needsinfo
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by srkunze):

Replying to [comment:4 claudep]:


> Replying to [ticket:24347 srkunze]:

> > 'as_widget' has the parameter 'widget' which renders the field.
However, this parameter is not used all the time during the 'as_widget'
call.
>

> Sorry, but that's not true.

It is true.

> The widget parameter is used in `widget.render(...)` at the end of the
method.

I am not saying that this is the only possible place where the widget is
used.

> It's totally possible something is not working properly,

Please, carefully read my ticket again as I described what's wrong:

> The method 'data', which is (indirectly via 'value') called by


'as_widget' ALWAYS used the default widget of the field which leads to

issues like formatting etc.


> but then we'll need a more thorough example to demonstrate the issue.

Cf. my ticket again:

> The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

`BouldField.as_hidden` should always use the HiddenWidget during
processing `BoundField.as_widget`, but `BouldField.data` uses the default
widget which is not the HiddenWidget of course.

A more concise presentation of the issue:


`BoundField.as_hidden` ---> `BoundField.as_widget` ---> `BoundField.value`
---> `BoundField.data`

"--->" means "uses"

`BoundField.as_hidden` specifies the HiddenWidget when it calls
`BoundField.as_widget`
`BoundField.value` and `BoundField.data` do not respect the specified
widget

Hence, the output is flawed.

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

Django

unread,
Feb 17, 2015, 8:36:17 AM2/17/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution:

Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by srkunze):

* status: closed => new
* resolution: needsinfo =>


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

Django

unread,
Feb 20, 2015, 6:34:10 AM2/20/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by srkunze:

Old description:

> 'as_widget' has the parameter 'widget' which renders the field. However,


> this parameter is not used all the time during the 'as_widget' call.
>

> The method 'data', which is (indirectly via 'value') called by


> 'as_widget' ALWAYS used the default widget of the field which leads to

> issues like formatting etc.


>
> We recognized this issue when using 'show_hidden_initial=True' and
> widgets for datetime objects.
>
> The problem can also be observed when using BoundField.as_hidden as it
> uses 'as_widget' as well.
>
> cf.
> as_widget:
> https://github.com/django/django/blob/master/django/forms/forms.py#L526
> data:
> https://github.com/django/django/blob/master/django/forms/forms.py#L569
> as_hidden:
> https://github.com/django/django/blob/master/django/forms/forms.py#L562
>

> Versions: 1.4, 1.5, 1.6, 1.7, 1.8, master

New description:

'as_widget' has the parameter 'widget' which renders the field. However,
this parameter is not used all the time during the 'as_widget' call.

The method 'data', which is (indirectly via 'value') called by
'as_widget', ALWAYS uses the default widget of the field which leads to
issues like formatting etc.

We recognized this issue when using 'show_hidden_initial=True' and widgets
for datetime objects.

The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

Versions: 1.4, 1.5, 1.6, 1.7, 1.8, master

--

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

Django

unread,
Feb 25, 2015, 6:37:50 AM2/25/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by srkunze:

Old description:

> 'as_widget' has the parameter 'widget' which renders the field. However,


> this parameter is not used all the time during the 'as_widget' call.
>

> The method 'data', which is (indirectly via 'value') called by

> 'as_widget', ALWAYS uses the default widget of the field which leads to
> issues like formatting etc.


>
> We recognized this issue when using 'show_hidden_initial=True' and
> widgets for datetime objects.
>
> The problem can also be observed when using BoundField.as_hidden as it
> uses 'as_widget' as well.
>
> cf.
> as_widget:
> https://github.com/django/django/blob/master/django/forms/forms.py#L526
> data:
> https://github.com/django/django/blob/master/django/forms/forms.py#L569
> as_hidden:
> https://github.com/django/django/blob/master/django/forms/forms.py#L562
>

> Versions: 1.4, 1.5, 1.6, 1.7, 1.8, master

New description:

'as_widget' has the parameter 'widget' which renders the field. However,


this parameter is not used all the time during the 'as_widget' call.

The method 'data', which is (indirectly via 'value') called by
'as_widget', ALWAYS uses the default widget of the field which leads to
issues like formatting etc.

We recognized this issue when using 'show_hidden_initial=True' and widgets
for datetime objects.

The problem can also be observed when using BoundField.as_hidden as it
uses 'as_widget' as well.

cf.
as_widget:
https://github.com/django/django/blob/1.8a1/django/forms/forms.py#L566
data:
https://github.com/django/django/blob/1.8a1/django/forms/forms.py#L609
as_hidden:
https://github.com/django/django/blob/1.8a1/django/forms/forms.py#L602

Versions: 1.4, 1.5, 1.6, 1.7, 1.8, master

--

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

Django

unread,
Mar 2, 2015, 1:56:06 PM3/2/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by timgraham):

I'm also having trouble understanding your problem. It seems to me that
`BoundField.value/data` need to use the field's widget rather than
`HiddenInput` as the latter's `value_from_datadict()` doesn't know how to
handle each field's data. Can you offer a patch for this issue?

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

Django

unread,
Mar 3, 2015, 3:12:52 PM3/3/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.8alpha1
Severity: Normal | Resolution: needsinfo

Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => needsinfo


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

Django

unread,
Mar 6, 2015, 7:16:22 AM3/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:

Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by srkunze):

* status: closed => new

* version: 1.8alpha1 => 1.8beta1
* resolution: needsinfo =>


Comment:

> It seems to me that BoundField.value/data need to use the field's widget
rather than HiddenInput as the latter's value_from_datadict() doesn't know
how to handle each field's data.

It should use the HiddenInput all the time during the `as_hidden` call.

Otherwise, the data given into a form and the data returned (e.g. after a
POST) differs.

Widgets set with `hidden_initial=True` render their data two times: with
field.widget and with field.hidden_widget. Depending on whether or not its
a bound form, results in different formatting of the value/data.


This would be an example fix to show what I mean:
https://github.com/srkunze/django/commit/9480ce0c3853a47001bd12e339c263695c38978f


`hidden_initial=True` results in `only_initial=True`. That means the
'''hidden_initial parts''' of the POST data should not be changed.


PS:
Could somebody explain me the difference between '''data''' and
'''value''' with regards to BoundFields? Looks quite messy to me (e.g.
`BoundField.data` returns `value_from_datadict`; `prepare_value` gets
`data`, but it expects `value` according to its definition).

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

Django

unread,
Mar 6, 2015, 7:41:42 AM3/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by timgraham):

Thanks for the details. Unfortunately your patch doesn't pass the test
suite. Also, a new test showing the bug that's fixed is required. Will you
continue working on it?

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

Django

unread,
Mar 6, 2015, 8:11:12 AM3/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by srkunze):

You are welcome.

Before continue working on it, I would like to discuss whether my patch
makes sense and and I would like an answer on my PS.

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:13>

Django

unread,
Mar 6, 2015, 10:26:00 AM3/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by timgraham):

Could you write a test case so I can better understand the problem?

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:14>

Django

unread,
Mar 6, 2015, 11:25:30 AM3/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by srkunze):

I give it a try soon.


In the meantime, I would appreciate it if you could elaborate on this:

> Could somebody explain me the difference between '''data''' and
'''value''' with regards to BoundFields? Looks quite messy to me (e.g.
`BoundField.data` returns `value_from_datadict`; `prepare_value` gets
`data`, but it expects `value` according to its definition).

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:15>

Django

unread,
Mar 6, 2015, 12:06:17 PM3/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by timgraham):

I think the docstrings explain the difference between `data` and `value`.
I wouldn't get caught up in the fact that `prepare_value()` is called with
a variable named `data` even though its parameter is named `value`.

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:16>

Django

unread,
Mar 17, 2015, 7:32:55 AM3/17/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by srkunze):

I hope this illustrates our problem:
https://github.com/srkunze/django/commits/add_test_24347

In case of an error of the form (thus, the form needs to be re-rendered),
the hidden-initial should be re-rendered with the exact same value string
as it was rendered in unbound state.

Each different state of the form (corresponding to each written test):

unbound
bound + changed
bound + unchanged

shows a different behaviour (fails, fails, succeeds) which is unfortunate
for our internal testing library.

Replying to [comment:16 timgraham]:


> I think the docstrings explain the difference between `data` and
`value`. I wouldn't get caught up in the fact that `prepare_value()` is
called with a variable named `data` even though its parameter is named
`value`.

Unfortunately, docstring explains data by saying "data" and value by
saying "value". Thus, no relationship between data and value is defined
clearly.

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:17>

Django

unread,
Mar 19, 2015, 6:51:13 PM3/19/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by timgraham):

I think datetimes maybe complicating the issue. It seems like at least one
of the issues is that for the following form:
{{{
class MyForm(forms.Form):
foo = forms.IntegerField(initial=1, show_hidden_initial=True)

form = MyForm({'foo': 5})
}}}
You expect the hidden input to be rendered with "1" instead of "5".
{{{
<label for="id_foo">Foo:</label>
<input id="id_foo" type="number" value="5" name="foo">
<input id="initial-id_foo" type="hidden" value="5" name="initial-foo">
}}}
Is that correct?

By the way, I tried looking at your tests, but they didn't pass even when
I uncommented "# uncomment to see changes with correctly formatted hidden-
initial" -- not sure if that was intended or not?

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:18>

Django

unread,
Mar 20, 2015, 9:43:25 AM3/20/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by srkunze):

Replying to [comment:18 timgraham]:


> I think datetimes maybe complicating the issue.

Unfortunately, it is that complicated. Formatting (and its consistency
over the life-time of the form) is the issue here. That is why I chose
date inputs.

Replying to [comment:18 timgraham]:


> It seems like at least one of the issues is that for the following form:
> {{{
> class MyForm(forms.Form):
> foo = forms.IntegerField(initial=1, show_hidden_initial=True)
>
> form = MyForm({'foo': 5})
> }}}

Actually, it should look like this as browsers send `initial-foo` as well:

{{{
form = MyForm({'foo': 5, 'initial-foo': 1})
}}}

> You expect the hidden input to be rendered with "1" instead of "5".
> {{{
> <label for="id_foo">Foo:</label>
> <input id="id_foo" type="number" value="5" name="foo">
> <input id="initial-id_foo" type="hidden" value="5" name="initial-foo">
> }}}
> Is that correct?

Interesting. You accidentally found another error.

I created another commit and added more tests to cover all that.

> By the way, I tried looking at your tests, but they didn't pass even
when I uncommented "# uncomment to see changes with correctly formatted

hidden-initial" -- not sure if that was intended or not?

The comments were currently not intended to make the tests pass. They just
represent how **well-formed** POST data would look like IF the unbound
form would have produced correctly formatted hidden-initial data.

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:19>

Django

unread,
Mar 20, 2015, 9:57:50 AM3/20/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage:
as_widget | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by srkunze):

Here, we go:
https://github.com/srkunze/django/commit/c1fdbeeb19a41b2f3dcc09f501bd5ff9298b846d

14 tests now:
{{{
D1) FAILED test_boundfield__unbound_form__date
D2) FAILED test_boundfield__changed_bound_form__date
D3) FAILED test_boundfield__changed_bound_form__bogus_initial__date
D4) FAILED test_boundfield__changed_bound_form__missing_initial__date
D5) SUCCEEDED test_boundfield__unchanged_bound_form__date
D6) SUCCEEDED test_boundfield__unchanged_bound_form__missing_initial__date

I1) SUCCEEDED test_boundfield__unbound_form__integer
I2) FAILED test_boundfield__changed_bound_form__integer
I3) FAILED test_boundfield__changed_bound_form__bogus_initial__integer
I4) FAILED
test_boundfield__changed_bound_form__missing_initial__integer
I5) SUCCEEDED test_boundfield__unchanged_bound_form__integer
I6) SUCCEEDED
test_boundfield__unchanged_bound_form__missing_initial__integer
}}}


**unbound_form** - should be clear
**changed_bound_form** - form with data that has changed with regard to
initial
**unchanged_bound_form** - form with data that has not changed with regard
to initial
**bogus_initial** - user changed hidden initial
**missing_initial** - browser did not send hidden initial

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:20>

Django

unread,
Mar 20, 2015, 10:54:25 AM3/20/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage: Accepted
as_widget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 1 => 0
* stage: Unreviewed => Accepted


Comment:

Well, I guess we can accept the ticket, but even after spending time
looking at it, I still don't have a good understanding of the problem(s)
or what a solution might look like.

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:21>

Django

unread,
Mar 21, 2015, 1:59:58 PM3/21/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage: Accepted
as_widget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by srkunze):

> Well, I guess we can accept the ticket, but even after spending time
looking at it, I still don't have a good understanding of the problem(s)

I actually hoped you would be the one telling me. :D

> or what a solution might look like.

After our conversation and looking at the test-cases, I am even unsure if
my patch would touch the heart of the problem.

That is, btw., why I asked about the relationship between data and value.
However, as it seems the problem lies even deeper.

--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:22>

Django

unread,
Mar 23, 2015, 1:07:44 PM3/23/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage: Accepted
as_widget, hidden, initial, |
hidden_initial |
Has patch: 1 | Needs documentation: 1

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

* keywords: BoundField, as_widget => BoundField, as_widget, hidden,
initial, hidden_initial
* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:23>

Django

unread,
May 6, 2015, 8:09:25 AM5/6/15
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: BoundField, | Triage Stage: Accepted
as_widget, hidden, initial, |
hidden_initial |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by timgraham):

* version: 1.8beta1 => master


--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:24>

Django

unread,
Jan 13, 2016, 9:56:36 AM1/13/16
to django-...@googlegroups.com
#24347: parameter 'widget' of BoundField.as_widget is ignored
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix

Keywords: BoundField, | Triage Stage: Accepted
as_widget, hidden, initial, |
hidden_initial |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by srkunze):

* status: new => closed
* resolution: => wontfix


--
Ticket URL: <https://code.djangoproject.com/ticket/24347#comment:25>

Reply all
Reply to author
Forward
0 new messages