You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi and thanks for the great package. We are making a field to hold ISO 3316 country codes, and we were tempted to use ISO_3166_1_ALPHA2_COUNTRY_CODES because it looked super convenient. Unfortunately, though, it's just a list of the country codes and so it can't be used as a choices field.
I figured there'd be a workaround so that we could do:
country = models.CharField(length=2, choices=ISO_3166_1_ALPHA2_COUNTRY_CODES)
But I couldn't think of anything I really liked except for:
ISO_3166_CHOICES = {i: i for i in ISO_3166_1_ALPHA2_COUNTRY_CODES}
That didn't really thrill me, so I looked in Github, and was amused to see that literally nobody has used this variable in a public repo. Go figure.
I wonder if it'd be more useful to have it as a dictionary. That'd allow it to be used in choices. This would work nicely:
{
"US": "United States",
"GB": "United Kingdom of Great Britain",
"UA": "Ukraine",
...
}
Any interest in this?
The text was updated successfully, but these errors were encountered:
mlissner
changed the title
Should ISO_3166_1_ALPHA2_COUNTRY_CODES be in choices format?
Should ISO_3166_1_ALPHA2_COUNTRY_CODES be in choices format instead of as a flat tuple?
Sep 26, 2023
Hi and thanks for the great package. We are making a field to hold ISO 3316 country codes, and we were tempted to use
ISO_3166_1_ALPHA2_COUNTRY_CODES
because it looked super convenient. Unfortunately, though, it's just a list of the country codes and so it can't be used as achoices
field.I figured there'd be a workaround so that we could do:
But I couldn't think of anything I really liked except for:
That didn't really thrill me, so I looked in Github, and was amused to see that literally nobody has used this variable in a public repo. Go figure.
I wonder if it'd be more useful to have it as a dictionary. That'd allow it to be used in
choices
. This would work nicely:Any interest in this?
The text was updated successfully, but these errors were encountered: