Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
¿Obtener el valor de un objeto IntegerChoices en Django?

Supongamos que tengo el siguiente código Django (3.2):

 class AType(models.IntegerChoices): ZERO = 0, 'Zero' ONE = 1, 'One' TWO = 2, 'Two' a = AType.ZERO

¿Cómo obtengo "Cero" (la cadena asociada con a )?

Esto es muy similar a esta pregunta , excepto que aquí solo tenemos el objeto IntegerChoices y no un objeto de modelo asociado.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puedes usar .label :

 >>> a = AType.ZERO >>> a.label 'Zero'
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!