Code

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#1679 closed enhancement (wontfix)

Decouple single vs. multiline widget choice from database storage type for CharField vs. TextField

Reported by: lalo.martins@… Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This patch makes the choice of limited vs. unlimited database storage (models.CharField vs. models.TextField) orthogonal to the choice of single vs. multiline widget (forms.TextField vs. forms.LargeTextField).

The fact that models.CharField used to use forms.TextField is an indication that something was wrong ;-)

For backwards compatibility, but much more importantly, because it's the reasonable thing to expect, the defaults are identical to the current behaviour. To get a multiline CharField, do: foo = CharField(maxlength=MAX_FOO, multiline_admin=True). Conversely, to get a single-line TextField: bar = TextField(multiline_admin=False). There -- now postgres users have no reason to use CharField anymore, unless there is a real and legitimate limit to the max size a value can have.

The argument multiline_admin was chosen to be consistant with radio_admin which is the only other similar argument I found.

Patch taken against magic-removal as of this post.

Attachments (1)

multiline_fields.patch (2.1 KB) - added by lalo.martins@… 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by lalo.martins@…

comment:1 Changed 8 years ago by lalo.martins@…

maybe this shold also trigger a validator that a non-multiline field can't contain '\n'? I'm not sure it's in scope, so I didn't code it.

comment:2 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Resolution set to wontfix
  • Status changed from new to closed

The newforms-admin changes will fix this by allowing to pass any widget you want. This is not worth changing and adding a new keyword argument right now.

comment:3 Changed 7 years ago by lalo.martins@…

In fact, I would mark this "fixed" rather than "wontfix"; I believe newforms-admin does fix this feature request, in a way much more elegant and flexible than my patch.

comment:4 Changed 7 years ago by anonymous

this is a test

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.