django - 导入错误以某种方式与 app_labels 相关
问题描述
Django==2.2.3
蟒蛇 3.7
我收到此错误:
from yandex.models import YandexGoals
ImportError: cannot import name 'YandexGoals' from 'yandex.models' (/home/michael/PycharmProjects/ads1/ads_manager/yandex/models.py)
当我在发生异常时停止在我的 IDE 中(即,我在任何异常时停止)并评估表达式“从 yandex.models 导入 YandexGoals”,我得到这个:
RuntimeError: Model class yandex_campaigns.models.YandexCampaignCommonTemplate doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
嗯,消息不同。让我们调查一下我们有什么:
INSTALLED_APPS = [
...
'yandex',
'yandex_campaigns',
]
yandex/models.py
class YandexGoals(models.Model):
...
yandex/apps.py
class YandexConfig(AppConfig):
name = 'yandex'
yandex_campaigns.apps.py
class YandexCampaignsConfig(AppConfig):
name = 'yandex_campaigns'
尽我所能,我看不出这里有任何缺陷。你能给我一脚吗?
解决方案
推荐阅读
- java - 在 mac 上使用 java.awt.FileDialog 时出错
- php - 为什么 laravel 在引用供应商视图时会出错?
- jupyter-notebook - 如何从带有参数的笔记本内部运行 ipynb 笔记本功能
- python - 如果我输入的是小数,如何使 int 不适用
- javascript - 表情符号无法正确显示或根本不显示
- python - 在 Plotly-Dash 仪表板中,如何选择输出数字并进行另一次计算?
- pandas - 如何对 Pandas 数据框进行条件计算?
- paypal-sandbox - .Net Core PayPal:客户端身份验证失败
- python - Pandas:从列标题中提取前 4 位数字
- android - NDK 缺少“平台”目录