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
yinzishao17
V2EX  ›  Python

请教 django 的权限管理问题。如何对业务操作进行权限管理。

  •  
  •   yinzishao17 · 2017-09-12 20:50:25 +08:00 · 2283 次点击
    这是一个创建于 2423 天前的主题,其中的信息可能已经有所发展或是发生改变。
    阅读了一些文档,自带的权限管理是基于 model 作为资源,有对应的权限。但是如果我想对一些操作,没有向对应的模型,例如具体到某个接口,进行限制,请问大家有什么想法可以分享一下?是将这类型的都当做是一个资源,自己创建一个 model,作为操作权限模型,然后具体到某个接口,就创建相应的 permission ??
    5 条回复    2017-09-15 09:29:16 +08:00
    cocoakekeyu
        1
    cocoakekeyu  
       2017-09-12 21:16:54 +08:00
    哈,就推荐我这个 cancan 库,轻量简单:

    https://www.v2ex.com/t/380614
    shiroming
        2
    shiroming  
       2017-09-12 21:41:06 +08:00 via Android
    drf has_permission
    ryanking8215
        3
    ryanking8215  
       2017-09-13 09:28:04 +08:00
    yinzishao17
        4
    yinzishao17  
    OP
       2017-09-14 17:49:55 +08:00
    @ryanking8215 这个是基于模型下,对具体某个 object 的权限控制,是更细粒度的权限区分。但我这个权限是一种很抽象的行为,没有具体的 model。我觉得这个应该不适宜
    ryanking8215
        5
    ryanking8215  
       2017-09-15 09:29:16 +08:00
    @yinzishao17 具体不太了解。但觉得某个接口,某个操作也可以具象到一个 model 或者一个 object,换句话说,用 model 去描述你的某个接口 /操作。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   969 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:09 · PVG 07:09 · LAX 16:09 · JFK 19:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.