この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:1
ページ更新者:T
更新日時:2018-12-18 01:06:42

タイトル: RuntimeError: Model class ~ doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
SEOタイトル: RuntimeError: Model class ~ doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

この記事の要点
  • Django の RuntimeError: Model class ~ doesn't declare an explicit app_label
  • 原因: 対象モデルを含むアプリが settings.pyINSTALLED_APPS に登録されていない
  • 対処: INSTALLED_APPS'myapp' または 'myapp.apps.MyappConfig' を追加
  • 別パターン: apps.py の name 属性が違っている場合も

 

エラー内容

RuntimeError: Model class ~ doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

 

発生条件/原因/対処法

runserver時に発生するエラー。

対象のモデルを含むアプリがsetting.pyのINSTALLED_APPSに登録されていないことが原因。