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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:09:49+00:00 2026-06-14T04:09:49+00:00

My goal is to be able to use get_FOO_display(), and so as far as

  • 0

My goal is to be able to use get_FOO_display(), and so as far as I understand I will have to have choices specified in the model field. At the same time I am wanting to render the form using a ModelForm as a RadioButton.

The problem I am having is that the default value of “——” that would be used in a dropdown select is showing up as one of my RadioButton options.

models.py

class Medication(models.Model):
    YESNO_CHOICES = [(0, 'No'), (1, 'Yes')]
    Allergies = models.BigIntegerField(verbose_name='Allergies:', choices=YESNO_CHOICES)

forms.py

I have tried just specifying a RadioButton widget in the ModelForm.

class mfMedication(ModelForm):
    class Meta:
        model = Medication
        widgets = {
        'Allergies': RadioSelect(),
        }

and also specifying the RadioButton with the CHOICES.

class mfMedication(ModelForm):
    class Meta:
        model = Medication
        widgets = {
        'Allergies': RadioSelect(choices=Medication.YESNO_CHOICES),
        }

In both cases I get three radiobuttons:

"": -------
0 : No
1 : Yes

The only way I do not get the “——-” is to remove choices=YESNO_CHOICES from my model field, but this stops get_FOO_display() from working.

Any approach that you have used to get this working would be greatly appreciated.

Thanks. JD.

  • 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-06-14T04:09:51+00:00Added an answer on June 14, 2026 at 4:09 am

    If you want to prevent displaying of ------- choice, you should specify empty_label=None in your form field.

    Also, I recomend you to use BooleanField for model and TypedChoiceField for form:

    models.py:

    class Medication(models.Model):
        Allergies = models.BooleanField('Allergies:')
    

    forms.py:

    class MedicationForm(forms.ModelForm):
        YESNO_CHOICES = ((0, 'No'), (1, 'Yes'))
        Allergies = forms.TypedChoiceField(
                         choices=YESNO_CHOICES, widget=forms.RadioSelect, coerce=int
                    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal is to be able to have the user select a range of
My goal is to be able to use $obj like this: print $obj->hello() .
My goal is to be able to use HttpUnit to crawl around my webpage
Hello so far been trying to use this line of code my goal is
My goal is to be able to call functions that are inside my JQuery
The goal is to be able to add a PDF file to the assets
The end goal of this part of my project is to be able to
I have toyed with a number of ideas to do this, but so far
I need to bea be able to use a static variable set in a
My goal is to be able to share configration settings amongst apps. For example

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.