INSTALLED_APPS中goods报错
来源:3-7 xadmin后台管理系统的配置
我爱吃肉肉
2019-12-25
在第一次启动xadmin后,再次启动goods应用报错:
INSTALLED_APPS = [
'goods.apps.GoodsConfig', # 写成goods时,不报错
]
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000001A6A2A0BF28>
Traceback (most recent call last):
File "D:\Envs\VueShop\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "D:\Envs\VueShop\lib\site-packages\django\core\management\commands\runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "D:\Envs\VueShop\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "D:\Envs\VueShop\lib\site-packages\django\core\management\__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "D:\Envs\VueShop\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "D:\Envs\VueShop\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\Envs\VueShop\lib\site-packages\django\apps\registry.py", line 112, in populate
app_config.import_models()
File "D:\Envs\VueShop\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "D:\Envs\VueShop\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "D:\django\project\MyShop\apps\user_operation\models.py", line 6, in <module>
from goods.models import Goods
File "D:\django\project\MyShop\apps\goods\models.py", line 8, in <module>
class GoodsCategory(models.Model):
File "D:\Envs\VueShop\lib\site-packages\django\db\models\base.py", line 108, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class goods.models.GoodsCategory doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
写回答
1回答
-
bobby
2019-12-26
apps文件中内容
from django.apps import AppConfig class GoodsConfig(AppConfig): name = 'goods' verbose_name = "商品"
尽量不要改里面的内容, 你复制过去试试 https://stackoverflow.com/questions/40206569/django-model-doesnt-declare-an-explicit-app-label 也可以参考一下这个
00
Python前后端分离开发Vue+Django REST framework实战
Django REST framework课程视频,RESTFul API前后端分离开发
2873 学习 · 2457 问题
相似问题