Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda