Django在模型数据迁移的时候报错:'%s' must supply a name attribute." % entry)

环境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了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值