RuntimeError: Model class luffy.apps.home.models.Banner doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

 # from luffy.apps.home import views 这种导是错的,不能从根目录里面导,因为从url解析,会逐步解析model,发现model没有在setting 里面注册,就会直接报错
RuntimeError: Model class luffy.apps.home.models.Banner doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
'''
 File "D:\PY\luffy1\luffy\luffy\apps\home\urls.py", line 3, in <module>
    from luffy.apps.home import views
  File "D:\PY\luffy1\luffy\luffy\apps\home\views.py", line 9, in <module>
    from . import models
  File "D:\PY\luffy1\luffy\luffy\apps\home\models.py", line 8, in <module>
'''
from . import views # 这种是对的,直接从当前目录到,django会跳过解析
posted @ 2022-05-26 16:17  #卧龙先生#  阅读(342)  评论(1编辑  收藏  举报