Skip to content

Instantly share code, notes, and snippets.

@JuniorLima
Created September 6, 2012 14:06
Show Gist options
  • Save JuniorLima/3656616 to your computer and use it in GitHub Desktop.
Save JuniorLima/3656616 to your computer and use it in GitHub Desktop.
Descrição do Choices em um template Django
{{ c.get_cargo_display }}
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)
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