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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:53:49+00:00 2026-05-21T15:53:49+00:00

I have been searching and looking through docs, but I want to ask and

  • 0

I have been searching and looking through docs, but I want to ask and confirm for the best solution here.

Trying to define model choices.

  1. ‘yes, no and not sure’ choice From Radio Select
  2. How would I define for Multiple Choices

Simple Example:
In my models.py, I have

class Property(models.Model):
    name = models.CharField()

class Feature(models.Model):
    YES_CHOICES = (       # example of 1, there can be only one selection
        ('YES', 'Yes'),
        ('NO', 'No'),
        ('NOT_SURE', 'Not Sure')
    )
    PARKING_CHOICES = (    # example of 2, there can be multiple selections
        ('GARAGE', 'Garage'),
        ('STREET', 'Street'),
        ('PRIVATE_LOT', 'Private Lot'),
        ('VALET', 'Valet'),
    )

    nearby_school = models.CharField(max_length=8, choices=YES_CHOICES)
    parking_options = models. MultipleChoiceField(choices=PARKING_CHOICES)

class PropertyFeature(models.Model)
    property = models.ForeignKey(Property)
    feature = models.ForeignKey(Feature)
    ...

Are those best ways to do it?

  1. Should I use NullBooleanField instead for yes, no , not sure question?
  2. Is that a correct way for defining and storing for multiple choice answers? Sometimes, I see people using manytomany objects.

Just want to use the most efficient and the easiest method offered from Django.

  • 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-21T15:53:49+00:00Added an answer on May 21, 2026 at 3:53 pm

    Yes, NullBoolean is appropriate, but if there are more options that don’t fit the profile of NullBoolean, I’m in favor of IntegerField for readability and consistency across options.

    Null could intuitively mean n/a, but as you add more single choice questions, I think it’s even more intuitive to use an IntegerField mapped to static variables.

    Also for this type of scenario where the user will probably filter properties based on these features, it’s useful not to have to special case Null in your dynamic query.

    Example:

    ...filter(Q(nearby_school__isnull=True) | Q(nearby_school='NO')),
        other_choice='SOME_CHOICE')
    # vs
    ...filter(Q(nearby_school=Feature.NOT_SURE) | Q(nearby_school=Feature.NO)), 
        other_choice=Feature.SOME_CHOICE)
    

    This ancient post still serves as a great reference:
    http://www.b-list.org/weblog/2007/nov/02/handle-choices-right-way/

    class Feature(models.Model):
        YES = 0
        NO = 1
        NOT_SURE = 2
        SOMETIMES = 3
        YES_CHOICES = ( 
            (YES, 'Yes'),
            (NO, 'No'),
            (NOT_SURE, 'Not Sure'),
            (SOMETIMES, 'Sometimes'), # extensible.
        )
    

    As for a multiple choice field, I do think using a m2m field is the easiest/best way.

    You could set up your forms.MultipleChoiceField to store data as a comma separated field & display appropriately, but the fact that you can query the m2m field easily is a huge benefit + it works right out of the box with ModelMultipleChoiceField.

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

Sidebar

Related Questions

I have been searching through a lot of questions but they don't ask or
Have done some searching through Stack Exchange answered questions but have been unable to
I have been searching through the internet for android practice problems , but unable
I have been searching through the internet and documentation but cannot find if MS
I have been searching other stackoverflow questions and also looking through the android developer
I have been searching and looking for Drawing text with outline onto images? Here
Have been searching how to convert a dictionary to a string. But the results
I have been searching for a solution to this and so far found nothing
I have been searching for quite a bit now but I have never been
I have been searching for an answer and trying out stuff for days now

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.