开发者

How to use the querylist object in Django template

开发者 https://www.devze.com 2023-03-17 08:20 出处:网络
Initially i had this code (r\'^list/fixed/$\', list_detail.object_list, fixedList) In t开发者_如何学JAVAemplate i use

Initially i had this code

(r'^list/fixed/$', list_detail.object_list, fixedList)

In t开发者_如何学JAVAemplate i use

{% for val in object_list %}

It worked fine as i used Generic list

But now i want to write my own view which does same

 object_list = model.objects.all()
 return render_to_response('lists.html', object_list)

But its not working.

how can pass the same object list to template as in Generic View


render_to_response() takes a dictionary of variables to use.

return render_to_response('lists.html', {'object_list': object_list})
0

精彩评论

暂无评论...
验证码 换一张
取 消