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

  • Home
  • SEARCH
  • 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 3854378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:36:51+00:00 2026-05-19T17:36:51+00:00

I have a django form that allows a user to select multiple options: CARDS

  • 0

I have a django form that allows a user to select multiple options:

CARDS = (
    ("visa", "Visa"),
    ("mastercard", "MasterCard"),
)

class PaymentForm(forms.ModelForm):
    credit_cards = forms.MultipleChoiceField(choices=CARDS, widget=forms.CheckboxSelectMultiple)
    # ... etc.

I have the form’s associated model setup as:

class Payment(models.Model):
    user = models.OneToOneField(User)
    credit_cards = models.CharField(choices=CARDS, max_length=100)
    # ... etc.

But I’m thinking that a CharField with the choices parameter can only accept a single choice because my form never validates and I get an error like:

Value u”[u’visa’]” is not a valid choice.

And it sure looks like a valid choice.

I’ve seen that some people get this working with a ManyToManyField on the model side (which I’d expect) but building a model just for a static list of credit card types seems overkill.

So: is there a specific model field type or different form configuration I should be using to support multiple selections from a pre-defined list of options?

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-19T17:36:51+00:00Added an answer on May 19, 2026 at 5:36 pm

    http://djangosnippets.org/snippets/1200/

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

Sidebar

Related Questions

I have a Django Form class defined likes this in Models : class AccountDetailsForm(forms.Form):
1] I have the following model: class UserReportedData(db.Model): #country selected by the user, this
I have created a django application. Using this app users can be created or
I have code that acts properly in FF, Safari and Chrome, however the result
I'm attempting to deal with uploading files in Django and I've hit a snag.
Curious about how developers more experienced with Django than I might handle this: I
{% include 'django.contrib.auth.views.login' %} I don't want to write everything by hand.. I hate
I'm using django-registration app to perform registration. After registration (no matter if successful or
This is my second foray into Ajax and I'm not quite sure how to
I'm building a preview function into the CMS for my website which uses the

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.