Last active
October 14, 2020 20:38
-
-
Save nelsoncbf/bdd0e1d2bc93c88c868e48b9364cdc68 to your computer and use it in GitHub Desktop.
Estados Brasileiros Python Array WTForms SelectField
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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