开发者

Use Django context processor or middleware to check for cookies on templates?

My Django app has Post ob开发者_高级运维jects. Each Post has an IntegerField that gets incremented whenever a certain link is clicked. When that link is clicked, I set a cookie to indicate that it has been clicked and prevent the user from clicking it again. Thus the cookie will look like so:

is_clicked=[1,2,3,4,5]

where the integers 1,2,3,4,5 are Post.id.

Should I do this using context processor, middleware, or something else?

Thanks!


Middleware. Specifically, the session middleware.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜