8.

RuntimeError: Model class ~ doesn't declare an explicit

編集
この記事の要点
  • 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に登録されていないことが原因。

 

編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. Invalid HTTP_HOST header: '...'. You may need to add '...' to ALLOWED_HOSTS
  2. CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
  3. django.utils.datastructures.MultiValueDictKeyError
  4. Forbidden (403) CSRF verification failed. Request aborted.
  5. ModuleNotFoundError: No module named 'MySQLdb'
  6. WARNINGS: ?: (mysql.W002) MySQL Strict Mode is not set for database connection
  7. Unknown column 'table_name.id' in 'field list'
  8. RuntimeError: Model class ~ doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
  9. get() returned more than one MynumberRegist -- it returned 2!
  10. django.db.utils.OperationalError: (2006, "Can't connect to MySQL server")
  11. 'include' is not defined