【问题标题】:Django Rest doesen't declate explicitDjango Rest 没有明确声明
【发布时间】:2019-10-30 09:51:10
【问题描述】:

我正在安装 django rest 框架,当我在 settings.py 的 INSTALLED_APPS 中添加 rest-framework 时,我收到如下错误:

Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'rest-framework'

Traceback (most recent call last):

RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

有什么想法吗?

【问题讨论】:

  • 在 settings.py 中显示INSTALLED_APPS

标签: python django django-rest-framework


【解决方案1】:

您似乎从已安装的应用中删除了内容类型。在你的 settings.py 中添加:

INSTALLED_APPS = [
    ...
    "django.contrib.contenttypes",
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 2017-03-05
    • 1970-01-01
    相关资源
    最近更新 更多