Created
July 23, 2012 14:34
-
-
Save decko/3163932 to your computer and use it in GitHub Desktop.
Atribuições - Exemplo
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
| class Mandato(models.Model): | |
| titular = models.ForeignKey(Pessoas, blank=True, null=True, related_name='titular') | |
| atribuicao = models.CharField('Atribuição', max_length=1, choices=(('P', 'Presidente'), ('V', 'Vice-Presidente'), ('D', 'Diretor'))) |
Assim consegue uma consulta ordenado pelo Presidente, Vice e Diretor:
Mandato.objects.all().order_by('atribuicao')Caso queria de baixo para cima:
Mandato.objects.all().order_by('-atribuicao')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refatorando sua classe: