I'm using Django, Python 3.7. I want to represent a US state field in my model. So I added this
from django.contrib.localflavor.us.models importUSStateField...classUsLocation(models.Model):
address_1 = models.CharField(_("address"), max_length=128)
address_2 = models.CharField(_("address cont'd"), max_length=128, blank=True)
city = models.CharField(_("city"), max_length=64, null=False)
state =USStateField(_("state"), null=False)
zip_code = models.CharField(_("zip code"), max_length=10, null=False)
Bu tthis is resulting in an "Unresolved reference 'USStateField'" in the import line. I'm not tied to using this library. Is there another way I can conveniently represent a US state and if not, what's wrong with the above?
( 6 months ago )
Per the docs, localflavor has been separated out into a third party library. You can follow the installation instructions here, then:
from localflavor.us.models importUSStateField...classUsLocation(models.Model):...