我最近升级到 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/