推荐学习书目
› 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
bingoAI
0.01D
V2EX  ›  Python

django 实现后台系统日志管理

  •  1
     
  •   bingoAI ·
    jiangbingo · Jun 29, 2016 · 8537 views
    This topic created in 3781 days ago, the information mentioned may be changed or developed.
    python+django 实现后台用户登录 注销 对应模块的增删改操作日志。
    请教如何实现?
    17 replies  •  2016-08-24 17:47:32 +08:00
    georgema1982
    georgema1982
    Jun 30, 2016
    1
    台用户登录、注销是现成的。但是你说的“对应模块的增删改操作日志”又是什么?
    chaegumi
    chaegumi
    Jun 30, 2016
    2
    这有啥好说的,就是建个记录表,插入记录数据呗
    FingerLiu
    FingerLiu
    Jun 30, 2016❤️2
    3
    捕获所有 model 的 post_save 和 post_delete signal, 然后在 handler 中判断 instance 和 操作类型,然后存入自己建的日志表。 增、改都会触发 post_save, 删会触发 post_delete
    bingoAI
    bingoAI
    OP
    Jun 30, 2016
    4
    @FingerLiu 想想也是这样,是在 create delete update 等方法加装饰器的方式?
    bingoAI
    bingoAI
    OP
    Jun 30, 2016
    5
    django 自带的 logging 不知能应用得上不?
    bingoAI
    bingoAI
    OP
    Jun 30, 2016
    8
    @FingerLiu 感谢,正是需要的, django 信号模块可以实现。
    xsseroot
    xsseroot
    Jun 30, 2016
    9
    你是打算记到数据库中还是文件里?文件可以使用 python 自带的 logging
    bingoAI
    bingoAI
    OP
    Jul 1, 2016
    10
    @xsseroot 要用表单显示 用户对指定模块的增删改操作。
    bingoAI
    bingoAI
    OP
    Jul 1, 2016
    11
    上面有朋友提出 django 的 signal 模块,不知道该如何实现?
    bingoAI
    bingoAI
    OP
    Jul 1, 2016
    12
    @georgema1982 django 做的后台管理系统,是多个表单。需要对各个表单里的 CUD 操作进行记录。
    harmy
    harmy
    Jul 1, 2016 via iPhone
    13
    楼主看看 django-reversion , http://django-reversion.readthedocs.io/en/stable/
    bingoAI
    bingoAI
    OP
    Jul 1, 2016
    14
    bingoAI
    bingoAI
    OP
    Jul 1, 2016
    15
    @chaegumi 模块太多了,在每个操作里写数据库加入操作记录是不是不符合设计原则哟?
    bingoAI
    bingoAI
    OP
    Jul 4, 2016
    16
    前来回复,解决方案是在每个API里直接写数据库。
    wangycc
    wangycc
    Aug 24, 2016
    17
    @jiangbingo 直接写数据库啥意思?能再明白点吗
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1355 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 19:44 · PVG 03:44 · LAX 11:44 · JFK 14:44
    ♥ Do have faith in what you're doing.