未定义wsgi应用程序名称'BASE_DIR'

问题描述 投票:0回答:1

我在pythonanywhere.com上部署了django应用。我看到这个错误。我搜了很多,但什么也没得到。我被wsgi困扰,不知道该怎么做。请帮助

2020-05-27 04:56:19,548: Error running WSGI application
2020-05-27 04:56:19,549: NameError: name 'BASE_DIR' is not defined
2020-05-27 04:56:19,549:   File "/var/www/rashidtaha_pythonanywhere_com_wsgi.py", line 15, in <module>
2020-05-27 04:56:19,549:     application = get_wsgi_application()
2020-05-27 04:56:19,549: 
2020-05-27 04:56:19,549:   File "/home/rashidtaha/.virtualenvs/rashidtaha.pythonanywhere.com/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-05-27 04:56:19,549:     django.setup(set_prefix=False)
2020-05-27 04:56:19,549: 
2020-05-27 04:56:19,549:   File "/home/rashidtaha/.virtualenvs/rashidtaha.pythonanywhere.com/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
2020-05-27 04:56:19,549:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2020-05-27 04:56:19,550: 
2020-05-27 04:56:19,550:   File "/home/rashidtaha/.virtualenvs/rashidtaha.pythonanywhere.com/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
2020-05-27 04:56:19,550:     self._setup(name)
2020-05-27 04:56:19,550: 
2020-05-27 04:56:19,550:   File "/home/rashidtaha/.virtualenvs/rashidtaha.pythonanywhere.com/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
2020-05-27 04:56:19,550:     self._wrapped = Settings(settings_module)
2020-05-27 04:56:19,550: 
2020-05-27 04:56:19,550:   File "/home/rashidtaha/.virtualenvs/rashidtaha.pythonanywhere.com/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
2020-05-27 04:56:19,550:     mod = importlib.import_module(self.SETTINGS_MODULE)
2020-05-27 04:56:19,550: 
2020-05-27 04:56:19,550:   File "/home/rashidtaha/rashidtaha.pythonanywhere.com/env/lib/python3.8/site-packages/isort/__init__.py", line 25, in <module>
2020-05-27 04:56:19,551:     from . import settings  # noqa: F401
2020-05-27 04:56:19,551: 
2020-05-27 04:56:19,551:   File "/home/rashidtaha/rashidtaha.pythonanywhere.com/env/lib/python3.8/site-packages/isort/settings.py", line 359, in <module>
2020-05-27 04:56:19,551:     STATIC_ROOT = os.path.join(BASE_DIR, 'static')
2020-05-27 04:56:19,551: ***************************************************
2020-05-27 04:56:19,551: If you're seeing an import error and don't know why,
2020-05-27 04:56:19,551: we have a dedicated help page to help you debug: 
2020-05-27 04:56:19,551: https://help.pythonanywhere.com/pages/DebuggingImportError/
python django wsgi pythonanywhere
1个回答
0
投票

听起来好像BASE_DIR未在设置文件中定义。以下内容取决于您的项目布局。但这是我在这些项目中使用的。

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

如果您共享文件结构,可以进行调整。

© www.soinside.com 2019 - 2024. All rights reserved.