Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
django filter by priority

I have a status model field which contain list of priorities which are given to the contacted person, from virgin to client, the virgin been the low priority and client the high priority, now the question is how can I filter them so I can show all contacts from highest to lowest, so this is the order that I need to show them client, qualified, contacted, virgin, this is the model field

class LeadContact(models.Model):
    status = models.CharField(max_length=10, 
                                  choices=LeadContactConstants.STATUSES,
                                  default=LeadContactConstants.STATUS_PRISTINE)

and choices:

class LeadContactConstants(object):
    STATUS_PRISTINE = "PRISTINE"
    STATUS_CONTACTED = "CONTACTED"
    STATUS_QUALIFIED = "QUALIFIED"
    STATUS_CLIENT = "CLIENT"

    STATUSES = ((STATUS_PRISTINE, "Virgin"),
                (STATUS_CONTACTED, "Contacted"),
                (STATUS_QUALIFIED, "Qualified"),
                (STATUS_CLIENT, "Client"))
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

virgin_data = LeadContact.objects.filter(status=LeadContact.STATUS_PRISTINE)
contacted_data = LeadContact.objects.filter(status=LeadContact.STATUS_CONTACTED)
qualified_data = LeadContact.objects.filter(status=LeadContact.STATUS_QUALIFIED)
client_data = LeadContact.objects.filter(status=LeadContact.STATUS_CLIENT)
order_data = list(client_data) + list(qualified_data) + list(contacted_data) + list(virgin_data) # Now order_data contains your data in this specific order. Client - qualified - contacted - virgin

If you want only spécific fields about your models, you can used values_list method.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda