Skip to content

Should ISO_3166_1_ALPHA2_COUNTRY_CODES be in choices format instead of as a flat tuple? #499

Open
@mlissner

Description

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions