(permissions)
降级时移除新增的权限
降级时移除新增的权限
降级时移除新增的权限
def downgrade_perms(permissions):
    """降级时移除新增的权限"""
    with transaction.atomic():
        content_type = ContentType.objects.get_for_model(WeChatApp)
        apps = WeChatApp.objects.all()
        for app in apps:
            Permission.objects.filter(
                content_type=content_type,
                codename__in=get_perm_names(app, permissions)
            ).delete()
def downgrade_perms ( permissions ) : with transaction . atomic ( ) : content_type = ContentType . objects . get_for_model ( WeChatApp ) apps = WeChatApp . objects . all ( ) for app in apps : Permission . objects . filter ( content_type = content_type , codename__in = get_perm_names ( app , permissions ) ) . delete ( )