Py学习  »  问与答

通用视图怎么设置cookie呢?

该用户已被注销---weibo • 10 年前 • 3073 次点击  
> class IndexView(generic.ListView):
>         template_name = 'bbs/index.html'
>         def get_context_data(self, **kwargs):
>                 context = super(IndexView, self).get_context_data(**kwargs)
>           self.response_class.set_cookie('cookiecity', value='上海')
>                 return context

这里面报错。看意思我知道是没有绑定,但是不知道怎么绑定?谢谢 unbound method set_cookie() must be called with TemplateResponse instance as first argument (got str instance instead)

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/878
 
3073 次点击  
文章 [ 1 ]  |  最新文章 10 年前