1
我正在對具有多個正確答案的選擇題進行評分。如果你得到所有正確的答案而不是不正確的答案,你只能得到一個答案。如何比較QueryDict
elif response.question.type == 'checkbox':
all_correct = False
my_answers = Answer.objects.filter(pk__in=response.answer)
correct_answers = Answer.objects.filter(question=response.question, correct=True)
// Can I just do this?
if my_answers == correct_answers:
all_correct = True
if all_correct:
total_correct += 1
不,你不能。因爲'.get'返回一個對象,'.filter'返回一個queryset。 – karthikr 2014-11-03 22:23:41
現在怎麼樣?與'.filter' – broinjc 2014-11-03 22:29:05