Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

530
Vistas
Django CheckboxSelectMultiple() widget - Form widget value not selected after saving data options

How to can I work with multiple select options and make these options selected to stay selected ?

Some application? Should I use any JS?

Is possible that my approach may be incomplete or miss something ...?

Context

I have the following model:

class AcademicPeople(models.Model):

    CATHEDRAL_PROFESSOR = 'CATHEDRAL'
    RESEARCH_PROFESSOR = 'RESEARCH'
    INSTITUTIONAL_DIRECTIVE = 'DIRECTIVE'

    OCCUPATION_CHOICES = (
        (CATHEDRAL_PROFESSOR, 'Cathedral Professor'),
        (RESEARCH_PROFESSOR, 'Research Professor'),
        (INSTITUTIONAL_DIRECTIVE, 'Institutional Directive'),
    )

    occupation = models.CharField(
        max_length=255,
        blank = False,
    )

In the forms.py I have:

from .models import
from django.forms.widgets import CheckboxSelectMultiple

class AcademicPeopleForm(forms.ModelForm):
    title = "Details"
    occupation = forms.MultipleChoiceField(
        required=False,
        label='Occupation',
        widget=CheckboxSelectMultiple(),
        choices=AcademicPeople.OCCUPATION_CHOICES
    )

    class Meta:
        model = AcademicPeople
        fields = ('occupation',)

UPDATE

My view is very basic, is the following:

class AccountSettingsUpdateView(LoginRequiredMixin, UpdateView):
    model = AcademicPeople
    form_class = AcademicPeopleForm
    success_url = reverse_lazy('dashboard')
    context_object_name = 'preferences'

When I go to my template using the browser, I get the checkbox select multiple rendered in checkboxes, I select some options and when I save, these options selected does not show their value.

enter image description here

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda