gpt4 book ai didi

django - 导入错误 : cannot import name update_all_contenttypes

转载 作者:行者123 更新时间:2023-12-04 06:59:30 26 4
gpt4 key购买 nike

我最近升级到 Django 1.8。在以前的 Django 版本中,以下导入没问题:

from django.contrib.contenttypes.management import update_all_contenttypes

但是 update_all_contenttypes似乎已在 Django 1.8 中被悄悄删除(它在 1.7.7 中存在)。我在 1.8 release notes 中没有看到任何内容关于它的删除......有谁知道该功能的现代替代品是什么?

最佳答案

目前尚不清楚为什么该功能在 1.8 中被删除,但现代替代品似乎只是重新发明了那个轮子:

from django.apps import apps
from django.contrib.contenttypes.management import update_contenttypes

def update_all_contenttypes(**kwargs):
for app_config in apps.get_app_configs():
update_contenttypes(app_config, **kwargs)

关于django - 导入错误 : cannot import name update_all_contenttypes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29550102/

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