Opened 17 years ago

Closed 17 years ago

#4084 closed (fixed)

models.fields.USStateField missing newforms Field

Reported by: polpak <polpak@…> Owned by: Adrian Holovaty
Component: Forms Version: 0.96
Severity: Keywords: models USStateField
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The model has no formfield method, so it consequently shows up as a non-validating text input. This is not desirable.

I've attached a patch to have it use the django.contrib.localflavor.usa.forms.USStateSelect Field, but there also appears to be a bug there with the init method of the newforms field, so I'll file a separate bug for that one

Attachments (2)

models_usstatefield.patch (708 bytes ) - added by polpak <polpak@…> 17 years ago.
patch to django/db/models/fields/init.py for 0.96
models_usstatefield.2.patch (764 bytes ) - added by polpak <polpak@…> 17 years ago.
fixed patch which uses the correct form field and widget

Download all attachments as: .zip

Change History (8)

by polpak <polpak@…>, 17 years ago

Attachment: models_usstatefield.patch added

patch to django/db/models/fields/init.py for 0.96

comment:1 by Chad Simons <polpak@…>, 17 years ago

Patch needs improvement: set
Resolution: invalid
Status: newclosed

Sorry, shouldn't try to do this so late at night. The original patch won't do. It uses the widget rather than the form field. This one should work correctly.

by polpak <polpak@…>, 17 years ago

Attachment: models_usstatefield.2.patch added

fixed patch which uses the correct form field and widget

comment:2 by polpak <polpak@…>, 17 years ago

Patch needs improvement: unset
Resolution: invalid
Status: closedreopened

comment:3 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:4 by Malcolm Tredinnick, 17 years ago

Resolution: wontfix
Status: reopenedclosed

I don't think this is a good change to make. The field should be validating already (it has a "clean" method), so I'm not sure what you mean by non-validating. It's reasonable to have it show up as a text field so that people can just quickly enter their state (either as an abbreviation or word).

If you want to use the !USStateSelect widget, you can pass that in as part of the constructor (all Field subclasses take a widget parameter). So the current behaviour is reasonable and it can be customised to taste in the normal way.

comment:5 by Malcolm Tredinnick, 17 years ago

Resolution: wontfix
Status: closedreopened

Whoops. This isn't about newforms at all. Reopening whilst I turn my brain on.

comment:6 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: reopenedclosed

(In [5130]) Fixed #4084 -- Added formfield() support to the USStateField model field.
Thanks, polpak@….

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