summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/views/readers.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/askbot/views/readers.py b/askbot/views/readers.py
index cccfce67..2560ac71 100644
--- a/askbot/views/readers.py
+++ b/askbot/views/readers.py
@@ -428,7 +428,9 @@ def question(request, id):#refactor - long subroutine. display question body, an
# TODO: Add unit test to catch the bug where precache_comments() is called above (before) reordering the accepted answer to the top
#Post.objects.precache_comments(for_posts=[question_post] + answers, visitor=request.user)
- if thread.accepted_answer: # Put the accepted answer to front
+ if thread.accepted_answer and thread.accepted_answer in answers:
+ #Put the accepted answer to front
+ #the second check is for the case when accepted answer is deleted
answers.remove(thread.accepted_answer)
answers.insert(0, thread.accepted_answer)