1. Create a form with at least one *HiddenInput* form field.
2. Override a method such as `as_p()` by calling `_html_output()` with:
a. A `normal_row` parameter containing the string "%(field_name)s"
b. A `row_ender` parameter which is *not* the last tag in `normal_row`
3. Attempt to render the form. This will result in a builtins.KeyError:
'field_name' message.
Under these conditions, BaseForm._html_output() attempts to create a new
row to hold the hidden input fields. When it does, it uses `normal_row %
{..}`, but the dictionary does not have the field "field_name" in it. This
causes a KeyError. On the other hand, if `normal_row` ends in a
`row_ender` tag, it doesn't create a new row, and the method succeeds.
--
Ticket URL: <https://code.djangoproject.com/ticket/23712>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> Steps to reproduce:
>
> 1. Create a form with at least one *HiddenInput* form field.
> 2. Override a method such as `as_p()` by calling `_html_output()` with:
> a. A `normal_row` parameter containing the string "%(field_name)s"
> b. A `row_ender` parameter which is *not* the last tag in `normal_row`
> 3. Attempt to render the form. This will result in a builtins.KeyError:
> 'field_name' message.
>
> Under these conditions, BaseForm._html_output() attempts to create a new
> row to hold the hidden input fields. When it does, it uses `normal_row %
> {..}`, but the dictionary does not have the field "field_name" in it.
> This causes a KeyError. On the other hand, if `normal_row` ends in a
> `row_ender` tag, it doesn't create a new row, and the method succeeds.
New description:
Steps to reproduce:
1. Create a form with at least one '''HiddenInput''' form field.
2. Override a method such as `as_p()` by calling `_html_output()` with:
a. A `normal_row` parameter containing the string "%(field_name)s"
b. A `row_ender` parameter which is *not* the last tag in `normal_row`
3. Attempt to render the form. This will result in a builtins.KeyError:
'field_name' message.
Under these conditions, BaseForm._html_output() attempts to create a new
row to hold the hidden input fields. When it does, it uses `normal_row %
{..}`, but the dictionary does not have the field "field_name" in it. This
causes a KeyError. On the other hand, if `normal_row` ends in a
`row_ender` tag, it doesn't create a new row, and the method succeeds.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:1>
* version: 1.7 => master
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:2>
* status: new => assigned
* owner: nobody => JMGordon
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:3>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:4>
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:5>
* needs_docs: 1 => 0
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:6>
* owner: JMGordon =>
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:7>
* owner: => raully7
* status: new => assigned
Comment:
I'll try to create a patch before this weekend.
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:8>
* easy: 1 => 0
Comment:
Did you see the existing [https://github.com/django/django/pull/3529 pull
request] and the questions on it?
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:9>
Comment (by raully7):
Replying to [comment:9 timgraham]:
> Did you see the existing [https://github.com/django/django/pull/3529
pull request] and the questions on it?
Sorry, I thought it's unsigned and wasn't aware of wadevries' pull
request.
And even worse, I just submitted another
[https://github.com/django/django/pull/3847 pull request]...
Sorry for bother your guys, I should be more careful.
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:10>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:11>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3f9ec12d9c9eff9a3b1a205d87c7e66587cf9967"]:
{{{
#!CommitTicketReference repository=""
revision="3f9ec12d9c9eff9a3b1a205d87c7e66587cf9967"
Fixed #23712 -- Fixed KeyError with BaseForm._html_output()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23712#comment:12>