Opened 11 years ago

Closed 9 years ago

#1665 closed enhancement (fixed)

[patch] Added "length" param to Field class

Reported by: robert.morris@… Owned by: nobody
Component: Core (Other) Version: master
Severity: minor Keywords: feature
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Pretty much what the title says: I wanted to be able to specify the "size" attribute of form field both in the admin interface and in views using manipulators. My post in django-users in an old thread on the issue stirred up a "yes it's goofy -- make a patch" suggestion. So I did.

First patch submission, so I hope I did it right :)

Attachments (2)

fields.py (40.7 KB) - added by robert.morris@… 11 years ago.
Modified to take a "length" parameter, used in "size" attribute of HTML form fields
fields.py.diff (1.3 KB) - added by robert.morris@… 11 years ago.

Download all attachments as: .zip

Change History (9)

Changed 11 years ago by robert.morris@…

Attachment: fields.py added

Modified to take a "length" parameter, used in "size" attribute of HTML form fields

Changed 11 years ago by robert.morris@…

Attachment: fields.py.diff added

comment:1 Changed 11 years ago by robert.morris

TODO: make a comprehensive list of the field types that this can be used for; I initially thought that it would be valid for any field type subclassed from TextField, but that's not always true. IntegerField, PhoneNumberField, and USStateField are at least some field types that don't specify the length keyword, even though they are subclassed from TextField.

comment:2 Changed 11 years ago by jbloom@…

I'm voting for this option as well.
It'll make the Admin screens more flexible and useful.
-Josh

comment:3 Changed 11 years ago by pb@…

Also see discussion in ticket #872.

comment:4 Changed 10 years ago by Malcolm Tredinnick

Before this can go into the tree, the TODO item from a couple of comments ago needs to be fixed (probably any field taking a maxlength attribute can also take size) and there should be a patch to the documentation (docs/model-api.txt) as well.

comment:5 Changed 10 years ago by Gary Wilson <gary.wilson@…>

Needs tests: set
Triage Stage: UnreviewedAccepted

accepted as per Adrian's comments on the mailing list thread.

comment:6 Changed 9 years ago by Philippe Raoult

Keywords: feature added

comment:7 Changed 9 years ago by James Bennett

Resolution: fixed
Status: newclosed

The newforms library exposes the ability to do this, I believe, in which case this is fixed.

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