环境python3,dango1.11.7,IDE: pycharm
Django在模型数据迁移的时候报错:'%s' must supply a name attribute." % entry)
错误类型为:AttributeError: type object 'AppConfig' has no attribute 'name'
racking file by folder pattern: migrations
Traceback (most recent call last):
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 140, in create
app_name = cls.name
AttributeError: type object 'AppConfig' has no attribute 'name'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "S:\PyCharm 2018.1.4\helpers\pycharm\django_manage.py", line 52, in <module>
run_command()
File "S:\PyCharm 2018.1.4\helpers\pycharm\django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "F:/python_2/MxShop\manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 338, in execute
django.setup()
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Users\yww\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 143, in create
"'%s' must supply a name attribute." % entry)
django.core.exceptions.ImproperlyConfigured: 'trade.apps.AppConfig' must supply a name attribute.
Process finished with exit code 1
百度了好久都没有。只能自己找。
最后发现是在seeting里面进行app注册时出错,
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users.apps.UsersConfig',
'DjangoUeditor',
'goods.apps.GoodsConfig',
#这是错误的,由于是点回车,太快,导致的
#trade.apps.AppConfig
'trade.apps.TradeConfig',
'user_operation.apps.UserOperationConfig',
]
改回来就OK了。