研发总结记录:处理Django中的错误 django.core.exceptions.ImproperlyConfigured

在运行项目,准备迁移时出现的如下错误:

Traceback (most recent call last):

  File "C:\py3_env\lib\site-packages\django\apps\config.py", line 107, in create

    entry = module.default_app_config

AttributeError: module 'restful' has no attribute 'default_app_config'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "C:\software\PyCharm 2017.3.3\helpers\pycharm\django_manage.py", line 43, in

    run_module(manage_file, None, '__main__', True)

  File "c:\python36\Lib\runpy.py", line 205, in run_module

    return _run_module_code(code, init_globals, run_name, mod_spec)

  File "c:\python36\Lib\runpy.py", line 96, in _run_module_code

    mod_name, mod_spec, pkg_name, script_name)

  File "c:\python36\Lib\runpy.py", line 85, in _run_code

    exec(code, run_globals)

  File "C:/SELF_MEDIA_PLATFORM/self_media_dev\manage.py", line 15, in

    execute_from_command_line(sys.argv)

  File "C:\py3_env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line

    utility.execute()

  File "C:\py3_env\lib\site-packages\django\core\management\__init__.py", line 357, in execute

    django.setup()

  File "C:\py3_env\lib\site-packages\django\__init__.py", line 24, in setup

    apps.populate(settings.INSTALLED_APPS)

  File "C:\py3_env\lib\site-packages\django\apps\registry.py", line 91, in populate

    app_config = AppConfig.create(entry)

  File "C:\py3_env\lib\site-packages\django\apps\config.py", line 110, in create

    return cls(entry, module)

  File "C:\py3_env\lib\site-packages\django\apps\config.py", line 40, in __init__

    self.path = self._path_from_module(app_module)

  File "C:\py3_env\lib\site-packages\django\apps\config.py", line 73, in _path_from_module

    "with a 'path' class attribute." % (module, paths))

django.core.exceptions.ImproperlyConfigured: The app module has multiple filesystem locations (['C:\\***\\restful', 'C:/***\\restful']); you must configure this app with an AppConfig subclass with a 'path' class attribute.

 

解决方案:

出现这种错误的原因之一是因为在Django工程路径中找不到此app的路径,需要在此app下新建一个包文件__init__.py 即可解决此问题。

你可能感兴趣的:(Python)