Guys,
I might be lazy or am blind! but the following code is returning ZERO! items, while very well i know there is some items in the list,
View:
def post_answer(request, quest_id=None):
answer_list = Answer.objects.filter
(questionis__pk=quest_id).select_related()
...
# if a put a print stmt here ( answer_list[0].answer ) there is
# data displayed on the console!!
return render_to_response('myapp/post_answer.html',{'answerobj':answer_list }} )
Template post_answer.html:
{% regroup answerobj.object_list by answer as ans_list %}{{ ans_list|length }}
....
the above code prints 0.
I must be goofing somewhere, pls assist
Paul
From stackoverflow
-
try : {% regroup answerobj by answer as ans_list %}{{ ans_list|length }} object_list isn't required.
-
Tries Bharath technique but still nothing!!
Strange thing is i've tried on other Models and worked perfect, its kinda a trick i use to debug my apps, see if the views send any data to the templates ...
Still stuck!!!
Daniel : This isn't an answer... delete it and move it to a comment on Bharath's post.Daniel : BTW, Bharath's answer is correct. make sure "answer" is actually an attribute of the "Answer" model
0 comments:
Post a Comment