gpt4 book ai didi

python - django.contrib.auth 中的哪个函数创建默认模型权限?

转载 作者:行者123 更新时间:2023-12-01 01:28:27 24 4
gpt4 key购买 nike

在 django 文档中它说:

These permissions will be created when you run manage.py migrate; the first time you run migrate after adding django.contrib.auth to INSTALLED_APPS, the default permissions will be created for all previously-installed models, as well as for any new models being installed at that time. Afterward, it will create default permissions for new models each time you run manage.py migrate (the function that creates permissions is connected to the post_migrate signal)

它表示创建这些权限的函数与 post_migration 信号有关。我想知道这是哪个函数,因为我需要在代码中以编程方式设置默认权限。

最佳答案

迁移后信号从 here 发出

class AuthConfig(AppConfig):
name = 'django.contrib.auth'
verbose_name = _("Authentication and Authorization")

def ready(self):
post_migrate.connect(
create_permissions,
dispatch_uid="django.contrib.auth.management.create_permissions"
)
...

权限是从 here 创建的

关于python - django.contrib.auth 中的哪个函数创建默认模型权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53134740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com