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 7693285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:03:17+00:00 2026-05-31T21:03:17+00:00

Django python problem: The select drop down returns the numeric value of the item.

  • 0

Django python problem: The select drop down returns the numeric value of the item. I can’t figure out how to get the text value of it.

Models.py

profile_types = (('0', "Yadda"), ('1', "Frank and beans"), ('2', "Type"), ('3', "Placeholder"),\
                ('4', "Another"), ('5', "And another"), ('6', "aaand another"),\
                 ('7', "Another"), ('8', "Last Type"))

class Profile(models.Model):
     user = models.ForeignKey(User, null=True, unique=True)
     profile_types = models.CharField(max_length=2, choices=profile_types)

Forms.py

class EditProfileForm(forms.Form):
    profile_types = (('0', "Yadda"), ('1', "Frank and beans"), ('2', "Type"), ('3', "Placeholder"),\
                    ('4', "Another"), ('5', "And another"), ('6', "aaand another"),\
                     ('7', "Another"), ('8', "Last Type"))
    name = forms.CharField(max_length=100, required=False, widget=forms.TextInput(attrs={'class':'input-text'}) )
    about = forms.CharField(widget=forms.Textarea(attrs={'class':'input-text'}), required=False)
    org_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class':'input-text'}))
    org_type = forms.CharField(max_length=8, widget=forms.Select(choices=choices))
    profile_type = forms.CharField(max_length=4, widget=forms.Select(choices=choices))

Template:

<span>{{ profile.profile_type }}</span>

Which returns

  1  <-- (I'm trying to display "Frank and beans") -->
  • 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-31T21:03:18+00:00Added an answer on May 31, 2026 at 9:03 pm

    Your model has a method get_profile_type_display for this very purpose: https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_display

    Incidentally, if you wanted you could also search through the choices, either using dict(profile_types) or [b for a,b in profile_types if a == test_value] where test_value is the numeric value you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An Android/Iphone app will be accessing application data from the server. [Django-Python] How can
Problem: When I add UpdateCacheMiddleware and FetchFromCacheMiddleware to my Django project, I get unittest
I have a problem with python and Django. I have the error Error was:
Just begin my Python/Django experience and i have a problem :-) So i have
Are there some Go libraries for sessions? Using Python/Django there wasn't any problem. I
I am new to both django and python but I am beginning to get
I'm having a problem using imaplib on python 2.6 with the latest django svn.
I have a problem in getting the datetime.date() value in my django... when i
I encounter this problem : I have a django (python) server that serve XML
I have to solve this little problem in Python/Django and I'm wondering which is

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.