Opened 8 years ago

Closed 8 years ago

#4084 closed (fixed)

models.fields.USStateField missing newforms Field

Reported by: polpak <polpak@…> Owned by: adrian
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: UI/UX:

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

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by polpak <polpak@…>

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

comment:1 Changed 8 years ago by Chad Simons <polpak@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Resolution set to invalid
  • Status changed from new to closed

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.

Changed 8 years ago by polpak <polpak@…>

fixed patch which uses the correct form field and widget

comment:2 Changed 8 years ago by polpak <polpak@…>

  • Patch needs improvement unset
  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:3 Changed 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:4 Changed 8 years ago by mtredinnick

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

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 Changed 8 years ago by mtredinnick

  • Resolution wontfix deleted
  • Status changed from closed to reopened

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

comment:6 Changed 8 years ago by mtredinnick

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

(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