Opened 14 years ago
Closed 14 years ago
#16305 closed New feature (wontfix)
Create a form.TextField() form field
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | 1.3 |
Severity: | Normal | Keywords: | forms, default |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
To create a Text Field in a model, one calls:
models.TextField()
yet to create a TextField in a form, one must:
forms.CharField(max_length=200, widget=forms.TextInput({}))
Also, a ModelForm can bind to a model with a TextField by creating a CharField with a TextInput widget, like above.
Why not make a forms.TextField as a shortcut (simply a CharField with a different default widget).
The key benefit here would simply to make the Forms and Models symmetrical. As a developer, using a TextField in one place and then a CharField/widgetTextInput in another place to create the same effect seems very counter-intuitive, especially when the fix is so simple.
What do you think?
Change History (2)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This suggestion misses the reason why the distinction exists in the first place. The form layer deals with data. The widget layer deals with presentation. The decision to use Textarea or a TextInput is purely presentational -- it has no effect on the data handling.
This is a situation where we'd gain a minor simplification for a limit set of use cases, in exchange for obscuring the distinction between the two layers. Marking wontfix for this reason.
Sorry, all instance of TextInput above should read Textarea.