I am getting this error, "local variable 'stu_details' referenced before assignment". How can i fix it please.
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('/')
https://stackoverflow.com/questions/66947044/how-to-fix-unboundlocalerror-in-django-website April 05, 2021 at 08:32AM
没有评论:
发表评论