MultiSelect field in Django 2 is not working












0















I'm working on a project using Python(3.7) and Django(2) in which I need to create a multi-select field inside one of my form.



Here's what I have tried:



from models.py:



class ExperimentModel(models.Model):
user = models.ForeignKey(User, related_name='experiments',
on_delete=models.CASCADE)
name = models.CharField(max_length=255)
start_date = models.DateField()
change_date = models.DateField()
end_date = models.DateField()
assets = models.CharField(max_length=450, choices=choices)
goals = models.CharField(max_length=255, blank=True)
comments = models.TextField(max_length=1000)
created_at = models.DateTimeField(auto_now=True)


From forms.py:



class ExperimentForm(forms.ModelForm):
choices = (
('CO2 SCRUBBER', 'CO2 SCRUBBER'),
('CORN OIL', 'CORN OIL'),
('DRYERS', 'DRYERS'),
('ENVIRONMENTAL', 'ENVIRONMENTAL'),
('UTILITIES', 'UTILITIES'),
('LAB', 'LAB'),
('SIEVES', 'SIEVES'),
('GRAINS & MILLING', 'GRAINS & MILLING'),
('SEPARATION', 'SEPARATION'),
('AIR & GAS', 'AIR & GAS'),
('COOK', 'COOK'),
('EVAPORATION', 'EVAPORATION'),
('WATER', 'WATER'),
('STORAGE', 'STORAGE'),
('BOILER', 'BOILER'),
('FERMENTATION', 'FERMENTATION'),
('DISTILLATION', 'DISTILLATION'),
('BUILDING AND FACILITIES', 'BUILDING AND FACILITIES'),
('CHEMICAL', 'CHEMICAL'),
)
assets = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
choices=choices)

class Meta:
model = ExperimentModel
fields = ('user', 'name', 'start_date', 'change_date', 'end_date', 'assets',
'goals', 'comments')


From template.html:



<form method="POST" action="{% url 'new-experiment' %}">
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endif %}
{% csrf_token %}
<h2> Create new Experiment:</h2>
{# {{ form|crispy }}#}
<div class="form-group">
<input type="text" name="name" id="name" class="form-control input-lg"
placeholder="experiment name" tabindex="3" required>
</div>
<div class="form-group">
<label for="start_date"> Start Date </label>
<input type="date" name="start_date" id="start_date" class="form-control input-lg"
placeholder="start_date" tabindex="4" required>
</div>
<div class="form-group">
<label for="change_date"> Change Date </label>
<input type="date" name="change_date" id="change_date" class="form-control input-lg"
placeholder="change date" tabindex="4" required>
</div>
<div class="form-group">
<label for="end_date"> End Date </label>
<input type="date" name="end_date" id="end_date" class="form-control input-lg"
placeholder="end date" tabindex="4" required>
</div>
<div class="form-group">
<label for="assets"> Assets </label>
{# <input type="text" name="assets" id="assets" class="form-control input-lg"#}
{# placeholder="Assets" tabindex="3" required>#}
<select name="assets" class="form-control" id="assets" multiple>
<option value="CO2 SCRUBBER">CO2 SCRUBBER</option>
<option value="CORN OIL">CORN OIL</option>
<option value="DRYERS">DRYERS</option>
<option value="ENVIRONMENTAL">ENVIRONMENTAL</option>
<option value="UTILITIES">UTILITIES</option>
<option value="LAB">LAB</option>
<option value="SIEVES">SIEVES</option>
<option value="GRAINS & MILLING">GRAINS & MILLING</option>
<option value="SEPARATION">SEPARATION</option>
<option value="AIR & GAS">AIR & GAS</option>
<option value="COOK">COOK</option>
<option value="EVAPORATION">EVAPORATION</option>
<option value="WATER">WATER</option>
<option value="STORAGE">STORAGE</option>
<option value="BOILER">BOILER</option>
<option value="FERMENTATION">FERMENTATION</option>
<option value="BUILDING AND FACILITIES">BUILDING AND FACILITIES</option>
<option value="CHEMICAL">CHEMICAL</option>
</select>
</div>
<div class="form-group">
<label for="assets"> Goals </label>
<input type="text" name="goals" id="goals" class="form-control input-lg"
placeholder="Goals" tabindex="3" required>
</div>
<div class="form-group">
<label for="comments"> Comments </label>
<textarea name="comments" id="comments" class="form-control input-lg"
rows="5" required>
</textarea>
</div>
<hr class="colorgraph">
<div class="row">
<div class="col-md-12 float-right">
<input type="submit" value="Create" class="btn btn-primary btn-block btn-lg float-right"
tabindex="7" style="background-color: #7386D5; color: white">
</div>
{# <div class="col-xs-12 col-md-6"><a href="{% url 'register' %}"#}
{# class="btn btn-success btn-block btn-lg">Create New Account</a>#}
{# </div>#}
</div>
</form>


And here's the views.py:



def post(self, request, *args, **kwargs):
if request.method == 'POST':
post_data = request.POST.copy()
post_data.update({'user': request.user.pk})
form = ExperimentForm(post_data)
print('req submitted')
if form.is_valid():
print('form valid')
form.save(commit=False)
form.user = request.user
form.save()
return HttpResponseRedirect(reverse_lazy('all-experiments'))
else:
return HttpResponseRedirect(reverse_lazy('new-experiment'))


When I select the only one option from multiple assets, the experiment has been created but when select multiple options the request failed, what's can wrong here?



How can I achieve the multi-select functionality for assets for experiment Model?
Also, no error is displaying in the template, even though I have printed the errors in the template, but doesn't any error is displaying on the template.



Thanks in advance!










share|improve this question

























  • When you say that the request fails for multiple options, what happens specifically? Are you talking about a validation failure, or does the request completely fail with a traceback?

    – Will Keeling
    2 days ago











  • Request failed with status 302.

    – Abdul Rehman
    2 days ago











  • Status 302 is a HTTP redirect, which would make sense given you're returning an HttpResponseRedirect from your view. Do you end up on the new-experiment page when you expect to end up on the all-experiments page?

    – Will Keeling
    2 days ago













  • Yup, it’s end up on the new-experiment page & the record doesn’t save in the db table.

    – Abdul Rehman
    2 days ago
















0















I'm working on a project using Python(3.7) and Django(2) in which I need to create a multi-select field inside one of my form.



Here's what I have tried:



from models.py:



class ExperimentModel(models.Model):
user = models.ForeignKey(User, related_name='experiments',
on_delete=models.CASCADE)
name = models.CharField(max_length=255)
start_date = models.DateField()
change_date = models.DateField()
end_date = models.DateField()
assets = models.CharField(max_length=450, choices=choices)
goals = models.CharField(max_length=255, blank=True)
comments = models.TextField(max_length=1000)
created_at = models.DateTimeField(auto_now=True)


From forms.py:



class ExperimentForm(forms.ModelForm):
choices = (
('CO2 SCRUBBER', 'CO2 SCRUBBER'),
('CORN OIL', 'CORN OIL'),
('DRYERS', 'DRYERS'),
('ENVIRONMENTAL', 'ENVIRONMENTAL'),
('UTILITIES', 'UTILITIES'),
('LAB', 'LAB'),
('SIEVES', 'SIEVES'),
('GRAINS & MILLING', 'GRAINS & MILLING'),
('SEPARATION', 'SEPARATION'),
('AIR & GAS', 'AIR & GAS'),
('COOK', 'COOK'),
('EVAPORATION', 'EVAPORATION'),
('WATER', 'WATER'),
('STORAGE', 'STORAGE'),
('BOILER', 'BOILER'),
('FERMENTATION', 'FERMENTATION'),
('DISTILLATION', 'DISTILLATION'),
('BUILDING AND FACILITIES', 'BUILDING AND FACILITIES'),
('CHEMICAL', 'CHEMICAL'),
)
assets = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
choices=choices)

class Meta:
model = ExperimentModel
fields = ('user', 'name', 'start_date', 'change_date', 'end_date', 'assets',
'goals', 'comments')


From template.html:



<form method="POST" action="{% url 'new-experiment' %}">
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endif %}
{% csrf_token %}
<h2> Create new Experiment:</h2>
{# {{ form|crispy }}#}
<div class="form-group">
<input type="text" name="name" id="name" class="form-control input-lg"
placeholder="experiment name" tabindex="3" required>
</div>
<div class="form-group">
<label for="start_date"> Start Date </label>
<input type="date" name="start_date" id="start_date" class="form-control input-lg"
placeholder="start_date" tabindex="4" required>
</div>
<div class="form-group">
<label for="change_date"> Change Date </label>
<input type="date" name="change_date" id="change_date" class="form-control input-lg"
placeholder="change date" tabindex="4" required>
</div>
<div class="form-group">
<label for="end_date"> End Date </label>
<input type="date" name="end_date" id="end_date" class="form-control input-lg"
placeholder="end date" tabindex="4" required>
</div>
<div class="form-group">
<label for="assets"> Assets </label>
{# <input type="text" name="assets" id="assets" class="form-control input-lg"#}
{# placeholder="Assets" tabindex="3" required>#}
<select name="assets" class="form-control" id="assets" multiple>
<option value="CO2 SCRUBBER">CO2 SCRUBBER</option>
<option value="CORN OIL">CORN OIL</option>
<option value="DRYERS">DRYERS</option>
<option value="ENVIRONMENTAL">ENVIRONMENTAL</option>
<option value="UTILITIES">UTILITIES</option>
<option value="LAB">LAB</option>
<option value="SIEVES">SIEVES</option>
<option value="GRAINS & MILLING">GRAINS & MILLING</option>
<option value="SEPARATION">SEPARATION</option>
<option value="AIR & GAS">AIR & GAS</option>
<option value="COOK">COOK</option>
<option value="EVAPORATION">EVAPORATION</option>
<option value="WATER">WATER</option>
<option value="STORAGE">STORAGE</option>
<option value="BOILER">BOILER</option>
<option value="FERMENTATION">FERMENTATION</option>
<option value="BUILDING AND FACILITIES">BUILDING AND FACILITIES</option>
<option value="CHEMICAL">CHEMICAL</option>
</select>
</div>
<div class="form-group">
<label for="assets"> Goals </label>
<input type="text" name="goals" id="goals" class="form-control input-lg"
placeholder="Goals" tabindex="3" required>
</div>
<div class="form-group">
<label for="comments"> Comments </label>
<textarea name="comments" id="comments" class="form-control input-lg"
rows="5" required>
</textarea>
</div>
<hr class="colorgraph">
<div class="row">
<div class="col-md-12 float-right">
<input type="submit" value="Create" class="btn btn-primary btn-block btn-lg float-right"
tabindex="7" style="background-color: #7386D5; color: white">
</div>
{# <div class="col-xs-12 col-md-6"><a href="{% url 'register' %}"#}
{# class="btn btn-success btn-block btn-lg">Create New Account</a>#}
{# </div>#}
</div>
</form>


And here's the views.py:



def post(self, request, *args, **kwargs):
if request.method == 'POST':
post_data = request.POST.copy()
post_data.update({'user': request.user.pk})
form = ExperimentForm(post_data)
print('req submitted')
if form.is_valid():
print('form valid')
form.save(commit=False)
form.user = request.user
form.save()
return HttpResponseRedirect(reverse_lazy('all-experiments'))
else:
return HttpResponseRedirect(reverse_lazy('new-experiment'))


When I select the only one option from multiple assets, the experiment has been created but when select multiple options the request failed, what's can wrong here?



How can I achieve the multi-select functionality for assets for experiment Model?
Also, no error is displaying in the template, even though I have printed the errors in the template, but doesn't any error is displaying on the template.



Thanks in advance!










share|improve this question

























  • When you say that the request fails for multiple options, what happens specifically? Are you talking about a validation failure, or does the request completely fail with a traceback?

    – Will Keeling
    2 days ago











  • Request failed with status 302.

    – Abdul Rehman
    2 days ago











  • Status 302 is a HTTP redirect, which would make sense given you're returning an HttpResponseRedirect from your view. Do you end up on the new-experiment page when you expect to end up on the all-experiments page?

    – Will Keeling
    2 days ago













  • Yup, it’s end up on the new-experiment page & the record doesn’t save in the db table.

    – Abdul Rehman
    2 days ago














0












0








0








I'm working on a project using Python(3.7) and Django(2) in which I need to create a multi-select field inside one of my form.



Here's what I have tried:



from models.py:



class ExperimentModel(models.Model):
user = models.ForeignKey(User, related_name='experiments',
on_delete=models.CASCADE)
name = models.CharField(max_length=255)
start_date = models.DateField()
change_date = models.DateField()
end_date = models.DateField()
assets = models.CharField(max_length=450, choices=choices)
goals = models.CharField(max_length=255, blank=True)
comments = models.TextField(max_length=1000)
created_at = models.DateTimeField(auto_now=True)


From forms.py:



class ExperimentForm(forms.ModelForm):
choices = (
('CO2 SCRUBBER', 'CO2 SCRUBBER'),
('CORN OIL', 'CORN OIL'),
('DRYERS', 'DRYERS'),
('ENVIRONMENTAL', 'ENVIRONMENTAL'),
('UTILITIES', 'UTILITIES'),
('LAB', 'LAB'),
('SIEVES', 'SIEVES'),
('GRAINS & MILLING', 'GRAINS & MILLING'),
('SEPARATION', 'SEPARATION'),
('AIR & GAS', 'AIR & GAS'),
('COOK', 'COOK'),
('EVAPORATION', 'EVAPORATION'),
('WATER', 'WATER'),
('STORAGE', 'STORAGE'),
('BOILER', 'BOILER'),
('FERMENTATION', 'FERMENTATION'),
('DISTILLATION', 'DISTILLATION'),
('BUILDING AND FACILITIES', 'BUILDING AND FACILITIES'),
('CHEMICAL', 'CHEMICAL'),
)
assets = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
choices=choices)

class Meta:
model = ExperimentModel
fields = ('user', 'name', 'start_date', 'change_date', 'end_date', 'assets',
'goals', 'comments')


From template.html:



<form method="POST" action="{% url 'new-experiment' %}">
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endif %}
{% csrf_token %}
<h2> Create new Experiment:</h2>
{# {{ form|crispy }}#}
<div class="form-group">
<input type="text" name="name" id="name" class="form-control input-lg"
placeholder="experiment name" tabindex="3" required>
</div>
<div class="form-group">
<label for="start_date"> Start Date </label>
<input type="date" name="start_date" id="start_date" class="form-control input-lg"
placeholder="start_date" tabindex="4" required>
</div>
<div class="form-group">
<label for="change_date"> Change Date </label>
<input type="date" name="change_date" id="change_date" class="form-control input-lg"
placeholder="change date" tabindex="4" required>
</div>
<div class="form-group">
<label for="end_date"> End Date </label>
<input type="date" name="end_date" id="end_date" class="form-control input-lg"
placeholder="end date" tabindex="4" required>
</div>
<div class="form-group">
<label for="assets"> Assets </label>
{# <input type="text" name="assets" id="assets" class="form-control input-lg"#}
{# placeholder="Assets" tabindex="3" required>#}
<select name="assets" class="form-control" id="assets" multiple>
<option value="CO2 SCRUBBER">CO2 SCRUBBER</option>
<option value="CORN OIL">CORN OIL</option>
<option value="DRYERS">DRYERS</option>
<option value="ENVIRONMENTAL">ENVIRONMENTAL</option>
<option value="UTILITIES">UTILITIES</option>
<option value="LAB">LAB</option>
<option value="SIEVES">SIEVES</option>
<option value="GRAINS & MILLING">GRAINS & MILLING</option>
<option value="SEPARATION">SEPARATION</option>
<option value="AIR & GAS">AIR & GAS</option>
<option value="COOK">COOK</option>
<option value="EVAPORATION">EVAPORATION</option>
<option value="WATER">WATER</option>
<option value="STORAGE">STORAGE</option>
<option value="BOILER">BOILER</option>
<option value="FERMENTATION">FERMENTATION</option>
<option value="BUILDING AND FACILITIES">BUILDING AND FACILITIES</option>
<option value="CHEMICAL">CHEMICAL</option>
</select>
</div>
<div class="form-group">
<label for="assets"> Goals </label>
<input type="text" name="goals" id="goals" class="form-control input-lg"
placeholder="Goals" tabindex="3" required>
</div>
<div class="form-group">
<label for="comments"> Comments </label>
<textarea name="comments" id="comments" class="form-control input-lg"
rows="5" required>
</textarea>
</div>
<hr class="colorgraph">
<div class="row">
<div class="col-md-12 float-right">
<input type="submit" value="Create" class="btn btn-primary btn-block btn-lg float-right"
tabindex="7" style="background-color: #7386D5; color: white">
</div>
{# <div class="col-xs-12 col-md-6"><a href="{% url 'register' %}"#}
{# class="btn btn-success btn-block btn-lg">Create New Account</a>#}
{# </div>#}
</div>
</form>


And here's the views.py:



def post(self, request, *args, **kwargs):
if request.method == 'POST':
post_data = request.POST.copy()
post_data.update({'user': request.user.pk})
form = ExperimentForm(post_data)
print('req submitted')
if form.is_valid():
print('form valid')
form.save(commit=False)
form.user = request.user
form.save()
return HttpResponseRedirect(reverse_lazy('all-experiments'))
else:
return HttpResponseRedirect(reverse_lazy('new-experiment'))


When I select the only one option from multiple assets, the experiment has been created but when select multiple options the request failed, what's can wrong here?



How can I achieve the multi-select functionality for assets for experiment Model?
Also, no error is displaying in the template, even though I have printed the errors in the template, but doesn't any error is displaying on the template.



Thanks in advance!










share|improve this question
















I'm working on a project using Python(3.7) and Django(2) in which I need to create a multi-select field inside one of my form.



Here's what I have tried:



from models.py:



class ExperimentModel(models.Model):
user = models.ForeignKey(User, related_name='experiments',
on_delete=models.CASCADE)
name = models.CharField(max_length=255)
start_date = models.DateField()
change_date = models.DateField()
end_date = models.DateField()
assets = models.CharField(max_length=450, choices=choices)
goals = models.CharField(max_length=255, blank=True)
comments = models.TextField(max_length=1000)
created_at = models.DateTimeField(auto_now=True)


From forms.py:



class ExperimentForm(forms.ModelForm):
choices = (
('CO2 SCRUBBER', 'CO2 SCRUBBER'),
('CORN OIL', 'CORN OIL'),
('DRYERS', 'DRYERS'),
('ENVIRONMENTAL', 'ENVIRONMENTAL'),
('UTILITIES', 'UTILITIES'),
('LAB', 'LAB'),
('SIEVES', 'SIEVES'),
('GRAINS & MILLING', 'GRAINS & MILLING'),
('SEPARATION', 'SEPARATION'),
('AIR & GAS', 'AIR & GAS'),
('COOK', 'COOK'),
('EVAPORATION', 'EVAPORATION'),
('WATER', 'WATER'),
('STORAGE', 'STORAGE'),
('BOILER', 'BOILER'),
('FERMENTATION', 'FERMENTATION'),
('DISTILLATION', 'DISTILLATION'),
('BUILDING AND FACILITIES', 'BUILDING AND FACILITIES'),
('CHEMICAL', 'CHEMICAL'),
)
assets = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
choices=choices)

class Meta:
model = ExperimentModel
fields = ('user', 'name', 'start_date', 'change_date', 'end_date', 'assets',
'goals', 'comments')


From template.html:



<form method="POST" action="{% url 'new-experiment' %}">
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong>{{ error|escape }}</strong>
</div>
{% endfor %}
{% endif %}
{% csrf_token %}
<h2> Create new Experiment:</h2>
{# {{ form|crispy }}#}
<div class="form-group">
<input type="text" name="name" id="name" class="form-control input-lg"
placeholder="experiment name" tabindex="3" required>
</div>
<div class="form-group">
<label for="start_date"> Start Date </label>
<input type="date" name="start_date" id="start_date" class="form-control input-lg"
placeholder="start_date" tabindex="4" required>
</div>
<div class="form-group">
<label for="change_date"> Change Date </label>
<input type="date" name="change_date" id="change_date" class="form-control input-lg"
placeholder="change date" tabindex="4" required>
</div>
<div class="form-group">
<label for="end_date"> End Date </label>
<input type="date" name="end_date" id="end_date" class="form-control input-lg"
placeholder="end date" tabindex="4" required>
</div>
<div class="form-group">
<label for="assets"> Assets </label>
{# <input type="text" name="assets" id="assets" class="form-control input-lg"#}
{# placeholder="Assets" tabindex="3" required>#}
<select name="assets" class="form-control" id="assets" multiple>
<option value="CO2 SCRUBBER">CO2 SCRUBBER</option>
<option value="CORN OIL">CORN OIL</option>
<option value="DRYERS">DRYERS</option>
<option value="ENVIRONMENTAL">ENVIRONMENTAL</option>
<option value="UTILITIES">UTILITIES</option>
<option value="LAB">LAB</option>
<option value="SIEVES">SIEVES</option>
<option value="GRAINS & MILLING">GRAINS & MILLING</option>
<option value="SEPARATION">SEPARATION</option>
<option value="AIR & GAS">AIR & GAS</option>
<option value="COOK">COOK</option>
<option value="EVAPORATION">EVAPORATION</option>
<option value="WATER">WATER</option>
<option value="STORAGE">STORAGE</option>
<option value="BOILER">BOILER</option>
<option value="FERMENTATION">FERMENTATION</option>
<option value="BUILDING AND FACILITIES">BUILDING AND FACILITIES</option>
<option value="CHEMICAL">CHEMICAL</option>
</select>
</div>
<div class="form-group">
<label for="assets"> Goals </label>
<input type="text" name="goals" id="goals" class="form-control input-lg"
placeholder="Goals" tabindex="3" required>
</div>
<div class="form-group">
<label for="comments"> Comments </label>
<textarea name="comments" id="comments" class="form-control input-lg"
rows="5" required>
</textarea>
</div>
<hr class="colorgraph">
<div class="row">
<div class="col-md-12 float-right">
<input type="submit" value="Create" class="btn btn-primary btn-block btn-lg float-right"
tabindex="7" style="background-color: #7386D5; color: white">
</div>
{# <div class="col-xs-12 col-md-6"><a href="{% url 'register' %}"#}
{# class="btn btn-success btn-block btn-lg">Create New Account</a>#}
{# </div>#}
</div>
</form>


And here's the views.py:



def post(self, request, *args, **kwargs):
if request.method == 'POST':
post_data = request.POST.copy()
post_data.update({'user': request.user.pk})
form = ExperimentForm(post_data)
print('req submitted')
if form.is_valid():
print('form valid')
form.save(commit=False)
form.user = request.user
form.save()
return HttpResponseRedirect(reverse_lazy('all-experiments'))
else:
return HttpResponseRedirect(reverse_lazy('new-experiment'))


When I select the only one option from multiple assets, the experiment has been created but when select multiple options the request failed, what's can wrong here?



How can I achieve the multi-select functionality for assets for experiment Model?
Also, no error is displaying in the template, even though I have printed the errors in the template, but doesn't any error is displaying on the template.



Thanks in advance!







python django django-models django-forms django-2.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







Abdul Rehman

















asked 2 days ago









Abdul RehmanAbdul Rehman

943323




943323













  • When you say that the request fails for multiple options, what happens specifically? Are you talking about a validation failure, or does the request completely fail with a traceback?

    – Will Keeling
    2 days ago











  • Request failed with status 302.

    – Abdul Rehman
    2 days ago











  • Status 302 is a HTTP redirect, which would make sense given you're returning an HttpResponseRedirect from your view. Do you end up on the new-experiment page when you expect to end up on the all-experiments page?

    – Will Keeling
    2 days ago













  • Yup, it’s end up on the new-experiment page & the record doesn’t save in the db table.

    – Abdul Rehman
    2 days ago



















  • When you say that the request fails for multiple options, what happens specifically? Are you talking about a validation failure, or does the request completely fail with a traceback?

    – Will Keeling
    2 days ago











  • Request failed with status 302.

    – Abdul Rehman
    2 days ago











  • Status 302 is a HTTP redirect, which would make sense given you're returning an HttpResponseRedirect from your view. Do you end up on the new-experiment page when you expect to end up on the all-experiments page?

    – Will Keeling
    2 days ago













  • Yup, it’s end up on the new-experiment page & the record doesn’t save in the db table.

    – Abdul Rehman
    2 days ago

















When you say that the request fails for multiple options, what happens specifically? Are you talking about a validation failure, or does the request completely fail with a traceback?

– Will Keeling
2 days ago





When you say that the request fails for multiple options, what happens specifically? Are you talking about a validation failure, or does the request completely fail with a traceback?

– Will Keeling
2 days ago













Request failed with status 302.

– Abdul Rehman
2 days ago





Request failed with status 302.

– Abdul Rehman
2 days ago













Status 302 is a HTTP redirect, which would make sense given you're returning an HttpResponseRedirect from your view. Do you end up on the new-experiment page when you expect to end up on the all-experiments page?

– Will Keeling
2 days ago







Status 302 is a HTTP redirect, which would make sense given you're returning an HttpResponseRedirect from your view. Do you end up on the new-experiment page when you expect to end up on the all-experiments page?

– Will Keeling
2 days ago















Yup, it’s end up on the new-experiment page & the record doesn’t save in the db table.

– Abdul Rehman
2 days ago





Yup, it’s end up on the new-experiment page & the record doesn’t save in the db table.

– Abdul Rehman
2 days ago












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252769%2fmultiselect-field-in-django-2-is-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252769%2fmultiselect-field-in-django-2-is-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage