Home > Software engineering >  how to access second field in django choice field in django template
how to access second field in django choice field in django template

Time:01-27

In my django models i have a charfield status which is filled by choices

status = [
    ('Accepted','Accepted'),
    ('Pending','Acceptance Pending'),
    # ('Document_Pending','Document Pending'),
    ('Rejected','Rejected'),
    ('Pending_email_verification','Pending Email Verification'),
    ('pending_document','Document Pending'),
    ('pending_document_verification','Cerificate Verification Pending'),

]

in my template i want to print cerificate verfication pending but it always print pending_document_verfication which is expected because in the data it is stored but how can i print Certificate Verfication Pending

enter image description here

CodePudding user response:

You can use get_FOO_display() - [Django-doc] where FOO is the name of the field.

{{ obj.get_status_display }}
  •  Tags:  
  • Related