Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postal Code model field shows up as State list in Admin

Not sure, but I think this may be a bug?

Here is my model:

class Property(models.Model):
Name = models.CharField(max_length=40)
Description = models.TextField(default="Description Not Available")
Address = models.CharField(max_length=60, default="Not Available")
Address2 = models.CharField(max_length=60,null=True)
City = models.CharField(max_length=60, null=True)
State = usa_model.USStateField(null=True)
Code = usa_model.USPostalCodeField(null=True)
Phone = usa_model.PhoneNumberField(null=True)

enter image description here

Am I missing something?

-Kerry

like image 710
Kerry Hatcher Avatar asked Oct 12 '22 05:10

Kerry Hatcher


1 Answers

Perhaps you are looking for the US Zip Code Form Field?

The USPostalCodeField uses a list of the states + a few extras:

COFA_STATES = (
    ('FM', 'Federated States of Micronesia'),
    ('MH', 'Marshall Islands'),
    ('PW', 'Palau'),
)

At django.contrib.localflavor.us.us_states

# USStateField
STATE_CHOICES = tuple(sorted(US_STATES + US_TERRITORIES + ARMED_FORCES_STATES, key=lambda obj: obj[1]))

# USPostalCodeField
USPS_CHOICES = tuple(sorted(US_STATES + US_TERRITORIES + ARMED_FORCES_STATES + COFA_STATES, key=lambda obj: obj[1]))
like image 73
Yuji 'Tomita' Tomita Avatar answered Oct 14 '22 02:10

Yuji 'Tomita' Tomita