Opened 10 years ago

Closed 10 years ago

#3334 closed (fixed)

Dynamic Creation of newforms Persists field data

Reported by: Deryck Hodge <deryck@…> Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: Keywords:
Cc: deryck@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Attached is a patch to the tests for newforms, showing that when passing in fields to dynamically created forms, the fields are persisting across multiple instances of the form.

The current test fails as attached, returning field1, field2, field3, and field4 on the second print statement, when it should just return field3 and field4.

Attachments (1)

form_tests.diff (1.8 KB) - added by Deryck Hodge <deryck@…> 10 years ago.
A patch to tests/regressiontests/forms/tests.py to test instances of dynamically created forms return the right fields.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Deryck Hodge <deryck@…>

Attachment: form_tests.diff added

A patch to tests/regressiontests/forms/tests.py to test instances of dynamically created forms return the right fields.

comment:1 Changed 10 years ago by Adrian Holovaty

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 10 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [4437]) Fixed #3334 -- Changed newforms Form class construction so that appending to (or altering) self.fields affects only the instance, not the class. As a consequence, self.fields is created in Form.init(). The form metaclass now creates a variable self.base_fields instead of self.fields.

Note: See TracTickets for help on using tickets.
Back to Top