Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6120949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:43:42+00:00 2026-05-23T15:43:42+00:00

I try to implement enumartion structure in django such that class Status(): PENDING =

  • 0

I try to implement enumartion structure in django such that

class Status():
PENDING = 0
CONFIRMED = 1
DENIED = 2

STATUS =(
    (PENDING,_("salary_status_pending")),
    (CONFIRMED,_("salary_status_confirmed")),
    (DENIED,_("salary_status_denied")),
)

and in my model I use it like

class MyModel(models.Model):
    status = models.IntegerField(null=False, choices=Status.STATUS)

It works fine and if I want to get the label of enum field in my template I use
{{ mymodel.get_status_display }} and it writes the label _('key..') in my enum field instead of number which is explained in Django documents

However, what if I want to get the label in my view.py ?
I want to write a code below and it should give me the label of enum field instead of number

Status.CONFIRMED 

How can I achive this ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:43:43+00:00Added an answer on May 23, 2026 at 3:43 pm

    I found it.The code below does what I want

    Status.STATUS [Status.CONFIRMED ][1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I try to implement my class on this file I get an error
I try to implement the following code: <div class=clearid=usernameline>username:<input type=text name=username id=username style=border:1px solid
I try to implement the following function : template<typename T> class a { private:
I am looking to try and implement a project management system for myself that
I try to implement callback interface with COM techonlogy and have IDL like that:
I try to implement the abstract DbCommand class (like OdbcCommand, OleDbCommand, ...) but a
I try to implement User define Delegate.For that i did this code **- DelegateAppDelegate.h**
I try to implement an IntentService with a BroadcastReceiver that reacts on the SCAN_RESULTS_AVAILABLE_ACTION
I try to implement a TableCellEditor that conains some fields and a delete-button. It
I've try to implement integration tests for a working application (spring, hibernate, soap, cxf).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.