Opened 9 years ago

Closed 8 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@… 9 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@… 9 years ago.

Download all attachments as: .zip

Change History (9)

Changed 9 years ago by robert.morris@…

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

Changed 9 years ago by robert.morris@…

comment:1 Changed 9 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 9 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 9 years ago by pb@…

Also see discussion in ticket #872.

comment:4 Changed 9 years ago by mtredinnick

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 8 years ago by Gary Wilson <gary.wilson@…>

  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

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

comment:6 Changed 8 years ago by PhiR

  • Keywords feature added

comment:7 Changed 8 years ago by ubernostrum

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

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