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.
精彩评论