0

我需要将多个选择选项数据存储到数据库中。我尝试使用它,但它只需要一个选项。我给出了下面的代码。

模板

<select name="qualification" multiple>
<option value="">Select</option>
<script type="text/javascript">
                var functional=new Array("Any Graduates","Any UnderGraduates","Any PostGraduates","BE/BTech/MCA","BE/BTech","MCA","Other");
                for(var i=0;i<functional.length;i++)
                    document.write("<option value=\""+functional[i]+"\">"+functional[i]+"</option>");
            </script>
</select>

模型.py

class edu(models.Model):
    qualification = models.CharField(max_length=100)

视图.py

def jobpost(request):
     if request.method=='POST':
     qualification=request.POST.get('qualification')
     s=edu(qualification=qualification)
     s.save()
     return HttpResponseRedirect
4

1 回答 1

0

你可以试试

qualification = request.POST.getlist('qualification')
于 2013-05-06T06:33:09.470 回答