Django中内容的用户权限(User permissions for content in Django)

编程入门 行业动态 更新时间:2024-10-10 17:25:42
Django中内容的用户权限(User permissions for content in Django)

我有这个问题:新闻网站。 有两种类型的内容:免费和付费。 有三种类型的用户:用户(和访客)和订阅者。 用户可以看到免费内容。 并且可以评论内容。 客人可以看到免费内容。 并且无法对内容发表评论。 订户可以看到免费和付费内容。 并且可以评论内容。 每月订阅。

请提供出色的解决方案

I have this problem: News website. There are 2 types of content: Free and Paid. There are 3 types of users: The user (and Guest) and the Subscriber. The user can see free content. And can comment on the content. Guests can see the free content. And Can not comment on the content. The subscriber can see the free and paid content. And can comment on the content. Monthly subscription.

Please give excellent solutions.

最满意答案

首先,我建议你使用django rest_framework.it有很多很好的工具,你可以在任何你想要的平台上运行你的网站。只是一个与你的问题无关的建议。 对于你的问题你有两种方法首先使用django文件underestanding什么是权限model.with类Meta:

https://docs.djangoproject.com/en/1.10/ref/models/options/#permissions

第二,你可以使用django应用程序名称:django-guardian

请参阅doc: https : //django-guardian.readthedocs.io/en/stable/overview.html

first i recommend you to use django rest_framework.it has many good tools for that and you can run your site in anyplatform that you want.its just a advice not related to your question. for your problem you have 2 ways first use the django document for underestanding what is the permissions model.with class Meta:

https://docs.djangoproject.com/en/1.10/ref/models/options/#permissions

second you can use the django app name : django-guardian

see the doc: https://django-guardian.readthedocs.io/en/stable/overview.html

更多推荐

本文发布于:2023-08-08 00:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466677.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户权限   内容   Django   content   permissions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!