I have comments and I want to sort them with the last comment at the top of the list. However, it does not work. I get this error.
Caught TypeError while rendering: 'Comment' object is not iterable
I am not sure what causes this problem. Here are my views and model that may help.
Views
def home(request):
comments = Comment.objects.latest('datetime')
return render_to_response('home.html', {'comments':comments}, context_instance=RequestContext(request))
model
class Comment(models.Model):
name = models.CharField(max_length = 40)
datetime = models.DateTimeField(default=datetime.now)
note = models.TextField()
def __unicode__(self):
return unicode(self.name)
source
share