Opened 10 years ago

Closed 8 years ago

#9022 closed (fixed)

Allow US armed forces state codes for USStateField

Reported by: Daniel Pope <dan@…> Owned by: dougvanhorn
Component: contrib.localflavor Version: 1.0
Severity: Keywords:
Cc: dougvanhorn@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm not a Yank so I don't know how useful this is to you chaps over the pond. The official list of state codes supported by the US Postal Service was linked on and I checked to discover Django does not handle all of the codes:

Obviously this list runs contrary to #8425 but I thought this deserved a ticket in case you are discriminating against your boys in the Middle East, you UN-AMERICAN, COMMUNIST, CHEESE-EATING... er, wait. I think I'm getting my imported redneck epithets mixed up.

Attachments (2)

armed_forces.diff (1.8 KB) - added by dougvanhorn 10 years ago.
us_states patch to add Armed Forces entries.
usps_fields.diff (15.0 KB) - added by dougvanhorn 9 years ago.
US Postal Codes patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 10 years ago by dougvanhorn

Owner: changed from nobody to dougvanhorn
Status: newassigned
Triage Stage: UnreviewedAccepted

Definitely a bug. I'll attach a patch.

Changed 10 years ago by dougvanhorn

Attachment: armed_forces.diff added

us_states patch to add Armed Forces entries.

comment:2 Changed 10 years ago by dougvanhorn

Has patch: set

comment:3 Changed 10 years ago by Russell Keith-Magee

Resolution: wontfix
Status: assignedclosed

Based on Adrian's comment on #10308, marking wontfix.

comment:4 Changed 10 years ago by dougvanhorn

Resolution: wontfix
Status: closedreopened

I'm reopening this ticket because I don't think Adrian's reasoning is sound, based on the fact that there are non-US states in the module, such as:

  • American Somoa
  • Guam
  • Northern Mariana Islands
  • Puerto Rico
  • Virgin Islands

I would also point to the USStateField documentation:

class USStateField(Field):
    A form field that validates its input is a U.S. state name or abbreviation.
    It normalizes the input to the standard two-leter postal service
    abbreviation for the given state.

Which, rather plainly, states that the intent of the field is to represent two-letter postal service abbreviations.

If we're to believe should only represent the 50 states with a star on the flag, we need to patch the module to remove the US territories listed above.

comment:5 Changed 10 years ago by Carl Meyer

Resolution: wontfix
Status: reopenedclosed

As documented in the contributing docs, do not reopen tickets marked wontfix by a core committer. If you have something new to add, bring it up on the django-developers mailing list.

comment:6 Changed 10 years ago by James Bennett

Resolution: wontfix
Status: closedreopened
Triage Stage: AcceptedDesign decision needed

I actually did bring it up.

Back to DDN.

comment:7 Changed 9 years ago by dougvanhorn

I'm adding a patch to this ticket that will add a USPSStateField to the US localflavor package.

The USPostalCodeField will provide a model field and form fields which will validate USPS Postal Codes per

The patch includes regression test updated for forms and serializers_regress (though I'm unsure of what the serializers_regress tests are testing).

./ passes with 914 tests.

I'm not sure this is the right design choice, but since there seems to be disagreement as to what constitutes a US State, I figured I'd add a field specifically for US Postal Codes.

I'm not sure what this would mean to the USStateField, which, right now, is neither US States nor Postal Codes.

Changed 9 years ago by dougvanhorn

Attachment: usps_fields.diff added

US Postal Codes patch

comment:8 Changed 9 years ago by dougvanhorn

Cc: dougvanhorn@… added

comment:9 Changed 8 years ago by James Bennett

Resolution: fixed
Status: reopenedclosed

(In [15029]) Refactor the choices for localflavor's USStateField, and add new US postal code support. Fixes #14937 and #9022, refs #10308 and #8425.

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