Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#10969 closed (fixed)

django/contrib/localflavor/us/models.py update USStateField to act as a normal CharField with choices.

Reported by: pmclanahan Owned by: kmtracey
Component: contrib.localflavor Version: master
Severity: Keywords: usstatefield, charfield
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The current implementation of the USStateField model field in the localflavor/us module does not act like a normal CharField with choices. It does not cause the model to get a get_<fieldname>_display method, and it does not appear to obey blank=True rules like other CharFields would. It is for these reasons that I don't see why this can't be a simple subclass of django.db.models.fields.CharField.

Note: Possibly related to #4092.

Attachments (3)

localflavor.us.models.usstatefield.2.diff (2.4 KB) - added by pmclanahan 6 years ago.
Updated version that actually works.
localflavor.us.models.usstatefield.3.diff (1.2 KB) - added by pmclanahan 6 years ago.
One more try, this time without appending.
localflavor.us.models.usstatefield.diff (6.2 KB) - added by pmclanahan 5 years ago.

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by pmclanahan

Updated version that actually works.

Changed 6 years ago by pmclanahan

One more try, this time without appending.

comment:1 Changed 6 years ago by pmclanahan

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to pmclanahan
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 6 years ago by Alex

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

Changed 5 years ago by pmclanahan

comment:3 Changed 5 years ago by pmclanahan

  • Needs tests unset
  • Owner changed from pmclanahan to kmtracey
  • Status changed from assigned to new

Patch updated with tests.

comment:4 Changed 5 years ago by kmtracey

So #4092 notes the same problem but takes a different approach on fixing, introducing a new type of Widget (NullSelect), plus changing all(?) localflavor widgets to use this new type. The patch here just changes the field type for the US state field. Other localflavors don't need updating because they don't actually define fields, is that right? I'm just wondering if there is a problem with all these other localflavor lists that still needs to be dealt with or if the fix here resolves both this ticket and #4092. While the patches on #4092 touch all these different localflavors the actual problem description only mentions US states as being a problem...

comment:5 Changed 5 years ago by kmtracey

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

(In [11857]) Fixed #10969: Made US State field a CharField, fixing a few oddities in its behavior. Thanks Paul McLanahan.

comment:6 Changed 5 years ago by kmtracey

(In [11859]) [1.1.X] Fixed #10969: Made US State field a CharField, fixing a few oddities in its behavior. Thanks Paul McLanahan.

r11847 from trunk.

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