Created
September 6, 2012 14:06
-
-
Save JuniorLima/3656616 to your computer and use it in GitHub Desktop.
Descrição do Choices em um template Django
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
{{ c.cargo }} |
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
{{ c.car }} |
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
{{ c.get_cargo_display }} |
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
CARGO_CHOICES = (('0','Diretor Geral'),('1','Coordenação de projetos'),('2','Engenheiros'),('3','Projetistas'),('4','Técnicos')) | |
class Colaborador(models.Model): | |
cargo = models.CharField('Cargo*',max_length=1,choices=CARGO_CHOICES) |
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
CARGO_CHOICES = (('0','Diretor Geral'),('1','Coordenação de projetos'),('2','Engenheiros'),('3','Projetistas'),('4','Técnicos')) | |
class Colaborador(models.Model): | |
cargo = models.CharField('Cargo*',max_length=1,choices=CARGO_CHOICES) | |
def car(self): | |
if self.cargo == '0': | |
cargu = 'Diretor Geral' | |
if self.cargo == '1': | |
cargu = 'Coordenador de projetos' | |
if self.cargo == '2': | |
cargu = 'Engenheiros' | |
if self.cargo == '3': | |
cargu = 'Projetistas' | |
if self.cargo == '4': | |
cargu = 'Técnicos' | |
return cargu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment