I am trying to get input from the user in a template, I am showing list of Groups in template available from the Group model in Django Auth Models and expecting multiple values. But it is only returning single value even selecting multiple options
from django.contrib.auth.models import Group
class MyForm(forms.ModelForm):
the_choices = forms.ModelMultipleChoiceField(queryset=Group.objects.all(),
required=False,
widget=forms.CheckboxSelectMultiple)
class Meta:
model = Group
exclude = ['name', 'permissions']
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
views.py
from .forms import MyForm
from django.shortcuts import render
from django.views.generic import View
class see(View):
def __init__(self):
pass
def get(self, request):
context ={}
context['form']= MyForm()
return render(request, "home.html", context)
def post(self, request):
print(request.POST.get('the_choices'))
return HttpResponse('Great!')
Template - Input Form Image
Output in Console
kindly refer to image 2, I expect 1 and 2 (group name preferred) in console but its returning only 2.

