Python Django getlist()错误?

Python Django getlist()错误?,python,django,Python,Django,我没有收到任何错误,但我知道数据库保存记录中的错误,这是getlist()中的错误吗?还是我在代码中遗漏了什么?请告诉我为什么数据库中保存了错误的记录 def corevalues(request): coregradelevel = request.GET.get('coregradelevel') coreperiod = request.GET.get('coreperiod') marking = StudentBehaviorMarking.objects.al

我没有收到任何错误,但我知道数据库保存记录中的错误,这是getlist()中的错误吗?还是我在代码中遗漏了什么?请告诉我为什么数据库中保存了错误的记录

def corevalues(request):
    coregradelevel = request.GET.get('coregradelevel')
    coreperiod = request.GET.get('coreperiod')
    marking = StudentBehaviorMarking.objects.all()
    teacher = request.GET.get('teacher')
    corevalues = CoreValues.objects.all().order_by('Display_Sequence')
    corevaluesdescription = CoreValuesDescription.objects.values('id','Description').distinct('Description').order_by('Description')
    corevaluesperiod = CoreValuesDescription.objects.filter(grading_Period=coreperiod).order_by('Display_Sequence')
    period = gradingPeriod.objects.filter(id=coreperiod).order_by('Display_Sequence')
    gradelevel = EducationLevel.objects.filter(id__in = coregradelevel).distinct().order_by('id')

    studentcorevalues = StudentsCoreValuesDescription.objects.filter(Teacher = teacher).filter(GradeLevel = gradelevel.values_list('Description'))\
        .values('Students_Enrollment_Records').distinct('Students_Enrollment_Records').order_by('Students_Enrollment_Records')

    student = StudentPeriodSummary.objects.filter(Teacher = teacher).filter(GradeLevel__in = gradelevel.values_list('id'))
这是我的html代码

<table class="tblcore">
        <tr>
            <td rowspan="2" colspan="2">Core Values</td>
            {% for core in corevalues %}
                <td colspan="8"><input type="hidden" value="{{core.id}}" name="core">{{core.Description}}</td>
            {% endfor %}
        </tr>
        <tr>
            {% for corevalues in corevaluesperiod %}
                <td colspan="4" style="font-size: 12px"><input type="hidden" value="{{corevalues.id}}" name="coredescription">{{corevalues.Description}}</td>
            {% endfor %}
        </tr>

        <tr>
            <td colspan="2">Student's Name</td>
            {% for corevalues in period %}
            <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
        {% endfor %}
        </tr>
        {% for students in student %}
        <tr>
            <td colspan="2"><input type="hidden" value="{{students.id}}" name="student">{{students.Students_Enrollment_Records.Students_Enrollment_Records.Students_Enrollment_Records.Student_Users}}</td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}" name="marking">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select>
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.id}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select>
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.id}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select>
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.id}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select>
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.id}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select>
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.id}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select>
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="m.id">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endfor %}
    </table>
我没有收到任何错误,但是

您选择的某些选项没有名称,这就是它无法获取所有数据的原因:

<form method="post" action="/studentbehavior/" id="myform" class="myform" style="width: 100%" enctype="multipart/form-data">{% csrf_token %}
    <table class="tblcore">
        <tr>
            <td rowspan="2" colspan="2">Core Values</td>
            {% for core in corevalues %}
                <td colspan="8"><input type="hidden" value="{{core.id}}" name="core">{{core.Description}}</td>
            {% endfor %}
        </tr>
        <tr>
            {% for corevalues in corevaluesperiod %}
                <td colspan="4" style="font-size: 12px"><input type="hidden" value="{{corevalues.id}}" name="coredescription">{{corevalues.Description}}</td>
            {% endfor %}
        </tr>

        <tr>
            <td colspan="2">Student's Name</td>
            {% for corevalues in period %}
            <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
        {% endfor %}
        </tr>
        {% for students in student %}
        <tr>
            <td colspan="2"><input type="hidden" value="{{students.id}}" name="student">{{students.Students_Enrollment_Records.Students_Enrollment_Records.Students_Enrollment_Records.Student_Users}}</td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}" >{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select  name="marking">
                    <option  >--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select  name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select  name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endfor %}
    </table>
    <input type="submit" value="Update">
</form>
<form method="post" action="/studentbehavior/" id="myform" class="myform" style="width: 100%" enctype="multipart/form-data">{% csrf_token %}
    <table class="tblcore">
        <tr>
            <td rowspan="2" colspan="2">Core Values</td>
            {% for core in corevalues %}
                <td colspan="8"><input type="hidden" value="{{core.id}}" name="core">{{core.Description}}</td>
            {% endfor %}
        </tr>
        <tr>
            {% for corevalues in corevaluesperiod %}
                <td colspan="4" style="font-size: 12px"><input type="hidden" value="{{corevalues.id}}" name="coredescription">{{corevalues.Description}}</td>
            {% endfor %}
        </tr>

        <tr>
            <td colspan="2">Student's Name</td>
            {% for corevalues in period %}
            <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
                        <td colspan="4">
                <input type="hidden" value="{{corevalues.id}}" name="coreperiod">Q {{corevalues.id}}
            </td>
        {% endfor %}
        </tr>
        {% for students in student %}
        <tr>
            <td colspan="2"><input type="hidden" value="{{students.id}}" name="student">{{students.Students_Enrollment_Records.Students_Enrollment_Records.Students_Enrollment_Records.Student_Users}}</td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}" >{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select  name="marking">
                    <option  >--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select  name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select  name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
            <td colspan="4">
                <select name="marking">
                    <option>--------</option>
                    {% for m in marking %}
                        <option value="{{m.Marking}}">{{m.Marking}}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endfor %}
    </table>
    <input type="submit" value="Update">
</form>
   for desc, m in enumerate(request.POST.getlist('marking')):
        coredesc = corevalues[desc]
        coredescription = CoreValuesDescription(id=coredesc)

    for student in request.POST.getlist('student'):
        students = StudentPeriodSummary(id=student)
        V_insert_data = StudentsCoreValuesDescription(
            #Teacher=teacher,
            Core_Values=coredescription,
            Marking=m,
            Students_Enrollment_Records=students,
            grading_Period = coreperiod,
        )
        V_insert_data.save()