V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
larkifly
V2EX  ›  Python

django 中如何获取一个页面的展示次数

  •  
  •   larkifly · 2014-06-13 15:18:26 +08:00 · 3084 次点击
    这是一个创建于 3624 天前的主题,其中的信息可能已经有所发展或是发生改变。
    需求是这样的:

    页面有个地方展示a信息,当这个页面被浏览N次后,就展示b信息


    我目前的做法是全局变量的做法
    2 条回复    2014-06-14 11:12:04 +08:00
    xingzhi
        1
    xingzhi  
       2014-06-13 22:46:53 +08:00   ❤️ 1
    使用redis或其它缓存系统做计数。

    用全局变量你考虑一下:
    代码更新了要重启应用怎么办?网站挂了怎么办,服务器重启了怎么办?
    计数如何清零?。。。
    larkifly
        2
    larkifly  
    OP
       2014-06-14 11:12:04 +08:00
    @xingzhi 感谢提醒,非常感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3933 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:05 · PVG 13:05 · LAX 22:05 · JFK 01:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.