【发布时间】:2021-04-05 00:32:47
【问题描述】:
我收到此错误,“分配前引用了局部变量 'stu_details'”。请问怎么解决。
views.py
def assignment_page(request):
if request.method == "POST":
get_course_name = request.POST.get('get_course_name')
add_courses_get = add_courses.objects.get(Course_Name=get_course_name)
stu_course_all_stu = add_courses.objects.filter(Course_Name=add_courses_get)
for all_stu_details in stu_course_all_stu:
for stu_details in all_stu_details.student.all():
id_ = stu_details.student_ID
name = stu_details.student_name
context3 = {"stu_details":stu_details, "id_":id_, "name": name, 'stu_course_all_stu':stu_course_all_stu}
return render(request, 'assignment_page.html', context3)
else:
return redirect('/')
【问题讨论】:
标签: python django django-views django-templates