V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
python30
V2EX  ›  Python

django 的权限问题 比如 有三个文章 1, 2, 3 这三个文章有不同的权限

  •  
  •   python30 · Jan 22, 2020 · 3708 views
    This topic created in 2287 days ago, the information mentioned may be changed or developed.
    django 的权限问题 比如 有三个文章 1,2,3 这三个文章有不同的权限,a 用户购买了 1, 3 的权限 。b 用户购买了 1,2 的权限, 这样 1 就可以查看 1,2 文章,不能查看 3 类似这样的权限系统设置,如何设置好点?
    3 replies    2020-01-22 13:12:46 +08:00
    dcalsky
        1
    dcalsky  
       Jan 22, 2020   ❤️ 1
    Django object permission
    kayseen
        2
    kayseen  
       Jan 22, 2020 via Android
    django 自带的权限管理最小颗粒好像是数据表,你这种需求应该在设计数据库的时候考虑
    Hstar
        3
    Hstar  
       Jan 22, 2020   ❤️ 1
    目前 django 自带的 permission 是使用 content_type 字段关联到某一张表,如果需要实现对表里某一条数据的权限,需要稍微改造下 permission 表,加一个 object_id 之类的字段,通过已有的 content_type 字段配合,实现 object permission
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3017 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 15:13 · PVG 23:13 · LAX 08:13 · JFK 11:13
    ♥ Do have faith in what you're doing.