summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2017-10-04 23:30:24 +0530
committeradityacp2017-10-04 23:30:24 +0530
commit81a9490e58db3b68fc1385680a080a89c5d68385 (patch)
treebf8d522362df69466db7cb88a3b61095f99c5573
parent81e30ab1b8f9647742695fea578fb4b21820f865 (diff)
downloadonline_test-81a9490e58db3b68fc1385680a080a89c5d68385.tar.gz
online_test-81a9490e58db3b68fc1385680a080a89c5d68385.tar.bz2
online_test-81a9490e58db3b68fc1385680a080a89c5d68385.zip
Change get_latest_answer in Answerpaper model to order by id
-rw-r--r--yaksh/models.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 49e028b..92076ab 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1284,10 +1284,8 @@ class AnswerPaper(models.Model):
}]
return q_a
- def get_latest_answer(self,question_id):
- all_answers = self.answers.filter(question=question_id)
- if all_answers:
- return all_answers[0]
+ def get_latest_answer(self, question_id):
+ return self.answers.filter(question=question_id).order_by("-id").last()
def get_questions(self):
return self.questions.filter(active=True)