从Django中删除(或隐藏)默认权限 [英] Remove (or hide) default Permissions from Django

查看:339
本文介绍了从Django中删除(或隐藏)默认权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个将有两个管理后台的Django应用程序。一个用于正常用户日常使用,默认用于更高级的任务和开发人员。

I'm developing a Django app that will have two administration backends. One for daily use by "normal" users and the default one for more advanced tasks and for the developers.

该应用程序使用一些自定义权限,但没有默认的权限。所以我目前正在寻找一种删除默认权限的方法,或者至少有一种方式可以将它们从每日管理员的后台中隐藏起来,而无需大的修改。

The application uses some custom permissions but none of the default ones. So I'm currently looking for a way to remove the default permissions, or at least a way to hide them from the "daily" admin backend without large modifications.

推荐答案

Django 1.7中引入的一个新功能是定义默认权限的功能。如文档所述,如果您设置此要清空,将不会创建任何默认权限。

A new feature introduced in Django 1.7 is the ability to define the default permissions. As stated in the documentation if you set this to empty none of the default permissions will be created.

一个工作示例是:

class Blar1(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=255, unique = True, blank = False, null = False, verbose_name= "Name")

    class Meta:
        default_permissions = ()

这篇关于从Django中删除(或隐藏)默认权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆