Answer the question
In order to leave comments, you need to log in
How to fix 'Comment' object is not reversible?
I need to display the comments in reverse order, but Django doesn't allow for looping, so I write the view like this:
class Comment2(TemplateView):
template_name = "registration/comments.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
comment = Comment.objects.get(pk=1)
conversely = reversed(comment)
context['comment'] = comment
context['conversely'] = conversely
return context
{% for item in conversely %}
'Comment' object is not reversible
line: conversely = reversed(comment)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question