Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nelsoncbf/bdd0e1d2bc93c88c868e48b9364cdc68 to your computer and use it in GitHub Desktop.
Save nelsoncbf/bdd0e1d2bc93c88c868e48b9364cdc68 to your computer and use it in GitHub Desktop.
Estados Brasileiros Python Array WTForms SelectField
from flask_wtf import FlaskForm
from wtforms.fields import SelectField
def opcoes_UF():
return [
("AC", "Acre"),
("AL", "Alagoas"),
("AP", "Amapá"),
("AM", "Amazonas"),
("BA", "Bahia"),
("CE", "Ceará"),
("DF", "Distrito Federal"),
("ES", "Espírito Santo"),
("GO", "Goiás"),
("MA", "Maranhão"),
("MT", "Mato Grosso"),
("MS", "Mato Grosso do Sul"),
("MG", "Minas Gerais"),
("PA", "Pará", "sigla"),
("PB", "Paraíba"),
("PR", "Paraná"),
("PE", "Pernambuco"),
("PI", "Piauí"),
("RJ", "Rio de Janeiro"),
("RN", "Rio Grande do Norte"),
("RS", "Rio Grande do Sul"),
("RO", "Rondônia"),
("RR", "Roraima"),
("SC", "Santa Catarina"),
("SP", "São Paulo"),
("SE", "Sergipe"),
("TO", "Tocantins")
]
class Estados(FlaskForm):
uf = SelectField(choices=[(uf[1], uf[0]) for uf in opcoes_UF()], validate_choice=True, validators=[DataRequired()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment