如何在模板中的extra_context中打印值
def getgeneric(request, page=0, paginate_by=20, **kwargs):
page_size = 1
return list_detail.object_list(
request,
queryset=Post.objects.published(),
paginate_by=page_size,
page=page,
extra_context={'my' : 1},
**kwargs
)
答案 0 :(得分:2)
与通常的上下文对象相同。在您的情况下,my
答案 1 :(得分:0)
http://docs.djangoproject.com/en/1.3/ref/generic-views/#django-views-generic-list-detail-object-list
{{ extra_context.my }}
<强>更新强>
我错了。
<强> urls.py
强>
from django.conf.urls.defaults import *
from t1.models import T
urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list', {
'queryset': T.objects.all(),
'extra_context': {
'my':1
}
})
)
包含模板: t1/templates/t1/t_list.html
{{ my }}
<hr>
{{ extra_context.my }}
返回
1
<hr>