Opened 17 years ago
Closed 17 years ago
#5469 closed (worksforme)
Document difference in cleaning between initial and data parameter when using dynamic initial parameters
Reported by: | Manuel Saelices | Owned by: | Manuel Saelices |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | newforms, sprintsept14 | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I think is important to note that dynamic initial
data created in a form is not cleaned, unlike data
parameter. It could causes developer fails like caused by ticket #5145. This is an example what I refer:
>>> class NewsForm(forms.Form): ... date = forms.DateField() ... title = forms.CharField() >>> f = NewsForm(initial={'date': 'not_a_date'}) >>> f.as_table() <tr><th><label for="id_date">Date:</label></th><td><input type="text" name="date" value="not_a_date" id="id_date" /></td></tr> <tr><th><label for="id_title">Title:</label></th><td><input type="text" name="title" id="id_title" /></td></tr>
Attachments (2)
Change History (7)
by , 17 years ago
Attachment: | newforms_docs.diff added |
---|
comment:1 by , 17 years ago
Keywords: | sprintsept14 added |
---|
by , 17 years ago
Attachment: | docs_newforms_txt.diff added |
---|
I merged my own docs from 5145 into the ones in the previous page.
comment:3 by , 17 years ago
Mmmm... I think your last sentence could be confusing for the user, because he doesn't know what is a MultiValued (docs has not written yet and besides his location is after this).
comment:4 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 17 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
The current docs explain this and actually use initial
as an example of a way to supply data which bypasses validation.
Documentation patch