Django 有问题的视图
我有这个 Django 通用视图:
def post_list(request, page=0, paginate_by=1, **kwargs):
page_size = getattr(settings,'BLOG_PAGESIZE', paginate_by)
return list_detail.object_list(
request,
queryset=Post.objects.published(),
paginate_by=page_size,
page=page,
**kwargs
)
post_list.__doc__ = list_detail.object_list.__doc__
并且我想将其发送到当前年份以在模板中使用它。谁能帮助我吗?
I have this Django generic view:
def post_list(request, page=0, paginate_by=1, **kwargs):
page_size = getattr(settings,'BLOG_PAGESIZE', paginate_by)
return list_detail.object_list(
request,
queryset=Post.objects.published(),
paginate_by=page_size,
page=page,
**kwargs
)
post_list.__doc__ = list_detail.object_list.__doc__
and I want to send it the current year to use it in the template. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过 < 传递年份code>extra_context,对于当年:
Pass the year in via
extra_context
, for the current year:您的核心问题是使用通用视图 - http://stdout.be/2010/ 05/25/generic-views-suck/
与原始代码相比,您更愿意维护或扩展哪些代码?
You core problem is using generic views - http://stdout.be/2010/05/25/generic-views-suck/
Compared to the original, which code would you rather maintain or extend?