Questions tagged [multiplechoicefield]

43 questions
1
vote
3 answers

MultipleChoiceField - invalid_choice error - Select a valid choice. SomeChoice is not one of the available choices

I am creating a form in django, hoping to allow users to delete some of their devices. When I click on the submit button of my form, I keep getting the message: Select a valid choice. is not one of the available choices. Here is my…
Rose
  • 2,619
  • 4
  • 20
  • 27
1
vote
1 answer

How to save ModelMultipleChoiceField in Django view?

I have a Subject model and a CustomUser model. During registration users can select multiple subjects. The following is my code in forms. forms.py class SignUpForm(forms.Form): ... subjects = forms.ModelMultipleChoiceField(label="Subjects", …
MiniGunnR
  • 5,590
  • 8
  • 42
  • 66
1
vote
0 answers

Loading MultipleChoiceField initial values from session variables

I'm trying to pass a list between two views and am currently using session variables to do so. def EnrollmentVerification(request): session_enrollments = Enrollment.objects.filter(id__in=request.session["enrollments"]) if request.method ==…
0
votes
1 answer

Unable to use `CheckboxSelectMultiple` for choices in wagtails `FieldPanel`: Form field validation raises an error

In a wagtail settings model I have a CharField-based choice field and want that to behave as a multi select in Wagtails FieldPanel. The choices are rendered correctly as multiple checkboxes, but on submit the form validation will raise an…
tombreit
  • 1,199
  • 8
  • 27
0
votes
2 answers

Django MultipleChoiceField callback

I'm kind of new in Django and I'm trying to fill back a listbox with the data previously saved in database. So when I display the HTML page, the choices initially stored in database will be highlighted. The listbox data are saved in this format…
Nico44044
  • 125
  • 8
0
votes
0 answers

Form attributes duplicating in '.controls' div when using CheckboxSelectMultiple widget with Crispy Forms

I have a form that's meant to filter results in a list view. I'm using HTMX to submit a GET request whenever the form changes, and I'm using Crispy Forms to render the form (including the hx attributes on the
tag). I've used this pattern…
0
votes
0 answers

django multiple checkbox values show a template?

from django import forms class MyForm(forms.Form): checkbox = forms.MultipleChoiceField( choices=[('apple', 'apple'), ('orange', 'orange')], widget=forms.CheckboxSelectMultiple ) urls from django.urls import path from .…
0
votes
3 answers

Django multiple choice field, form.save() overwrites all values resetting previous entries rather than adding new ones

I have a form which is intended to add a number of sections to a project. I am using a CheckboxSelectMultiple with a list of choices restricted to only those that have not previously been selected. So with a new empty project with no…
0
votes
1 answer

Where developers save choice options in Django?

For example i have a choice COLORS = ( ('red', 'Red'), ('blue', 'Blue'), ('yellow', 'Yellow'), ) Should i create a model like: class Color(models.Model): color = models.CharField(...) and create some color instances in…
Ihor
  • 97
  • 10
0
votes
2 answers

Getting FieldError for MultipleChoiceField in Django rest framework

I am trying to use MultipleChoiceField from django Rest Framework fields as described in this link: https://pypi.org/project/django-multiselectfield/ A part of my code snippet is as below: from rest_framework import fields CHOICES = ( …
0
votes
1 answer

Select a valid choice. ["objects"] is not one of the available choices. in Django

I'm going to create a form where the user can select any number of objects from the options.(MultipleChoiceField) Here are my files: DAY_CHOICES = ( ('saturday', 'شنبه'), ('sunday', 'یکشنبه'), ('monday', 'دوشنبه'), ('tuesday', 'سه…
rahnama7m
  • 865
  • 10
  • 38
0
votes
1 answer

Nintex choice control rule

Any help would be highly appreciated.I am working on Nintex form and currently stuck with this rule to be worked. I have first checkbox as YES/NO (Name: NA), trying to create a rule where automatically all the options (Name:Options) below…
0
votes
0 answers

Django model multiple select field but not multi select box

How to let user be multiple-choice in Django models? Do I need django-multiselectfield, but it's choices are user-defined, right?(sample 1), not the data from user models. I want to make multiple-choice users, not single choice, I pasted my code…
0
votes
1 answer

MultipleChoiceField : check all if nothing is checked

What I want to do seems simple : I have a MultipleChoiceField in a django form which proposes the id and pseudo of all books in a model named Dico : class FiltreMonoForm(forms.Form): dico_choices = [] for dic in…
0
votes
0 answers

Django forms: MultipleChoiceField does not select options from instance

I have a form from a model. Depending on "property_type" would be dynamically build a (or multiple) different field for "property_values". The result HTML form is right but the options for the multiple select field for "Property value" will not be…
Antonio Romero Oca
  • 1,196
  • 10
  • 31