llirik

Untitled

Oct 28th, 2021 (edited)
770
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def TestResult(request):
  2.     text = Text.objects.all().order_by("-id")[0:1].get()
  3.     this_week = text.week_number
  4.     qustions = TestQuestion.objects.filter(week_number=this_week)
  5.     ans_dict = {}
  6.     for question in qustions:
  7.         answers = TestAnswer.objects.filter(question=question)
  8.         ans_dict[question] = []
  9.         for ans in answers:
  10.             ans_dict[question].append(ans)
  11.  
  12.     data = {
  13.         'ans_dict': ans_dict,
  14.     }
  15.     return render(request, 'testresult.html', data)
RAW Paste Data