python - Django 在运行服务器时报错
问题描述
所以,我对 Django 的概念非常陌生,但我对 python 非常熟悉,并尝试使用 YouTube 学习 Django。事实证明,每当我按照他们提到的步骤尝试运行服务器时,都会遇到同样的错误。所以我也决定在 StackOverflow 上寻找一些答案,所有的答案都对我的问题没有任何用处。因此,我终于在这里发布了我的问题。
请帮忙。
我收到有关rest_framework和wsgi_application的错误消息
这是尝试运行服务器后返回的错误:
C:\Users\name\OneDrive\Documents\ZZZ\Coding\React-Django\music_app>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
July 02, 2021 - 18:06:25
Django version 3.2.4, using settings 'music_app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\name\anaconda3\lib\site-packages\django\utils\module_loading.py", line 13, in import_string
module_path, class_name = dotted_path.rsplit('.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\name\anaconda3\lib\site-packages\django\core\servers\basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "C:\Users\name\anaconda3\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "C:\Users\name\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\name\OneDrive\Documents\ZZZ\Coding\React-Django\music_app\music_app\wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "C:\Users\name\anaconda3\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "C:\Users\name\anaconda3\lib\site-packages\django\core\handlers\wsgi.py", line 127, in __init__
self.load_middleware()
File "C:\Users\name\anaconda3\lib\site-packages\django\core\handlers\base.py", line 40, in load_middleware
middleware = import_string(middleware_path)
File "C:\Users\name\anaconda3\lib\site-packages\django\utils\module_loading.py", line 15, in import_string
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
ImportError: rest_framework doesn't look like a module path
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\name\anaconda3\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\name\anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\name\anaconda3\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\name\anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 138, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Users\name\anaconda3\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "C:\Users\name\anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 65, in get_handler
return get_internal_wsgi_application()
File "C:\Users\name\anaconda3\lib\site-packages\django\core\servers\basehttp.py", line 50, in get_internal_wsgi_application
) from err
django.core.exceptions.ImproperlyConfigured: WSGI application 'music_app.wsgi.application' could not be loaded; Error importing module.
PS这些是我首先提到的链接:
- Django 配置不当:无法加载 WSGI 应用程序“myproject.wsgi.application”;导入模块出错
- django.core.exceptions.ImproperlyConfigured:无法加载 WSGI 应用程序“应用程序”
- Django:m 看起来不像模块路径
谢谢你。
解决方案
推荐阅读
- c# - 更新基类值,因此所有派生类也会更新
- python - 熊猫列数据作为绘图中的标记?
- javascript - 为数组中的特定项目分配不同的链接
- flutter - 如何对集合进行排序
在 Dart/Flutter 中按字母顺序排列? - angular - ngx-sipper-wrapper 在 angular8 中无法正常工作?
- docker - Docker 构建步骤名称不能以数字开头
- tableau-api - Tableau 地图报告
- java - Arquillian - 所有测试的单一部署
- spring - Spring Batch:在 StoppableTasklets 中实现 stop 方法
- ruby - 使用gets时如何更改字符串的格式