instead of for answer_option in question order_list order_answer answe

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# instead of
for answer_option in question.order_list:
order_answer = answer_option.form.save(commit=False)
order = order_answer.order
try:
order_answer = OrderAnswer.objects.get(answer=answer, answer_option=answer_option)
order_answer.order = order
except ObjectDoesNotExist:
order_answer.answer = answer
order_answer.answer_option = answer_option
order_answer.save()
# will be this
for answer_option in question.order_list:
order_answer = answer_option.form.save(commit=False)
order_answer.answer_option = answer_option
order_answer.answer = answer
order_answer.save()