【问题标题】:wsgi application name 'BASE_DIR' is not defined未定义 wsgi 应用程序名称“BASE_DIR”
【发布时间】:2020-09-14 01:39:09
【问题描述】:

我在 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】:

    听起来BASE_DIR 没有在设置文件中定义。 下面在某种程度上取决于您的项目布局。但这是我在其中一个项目中使用的。

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

    如果您愿意共享您的文件结构,可以对其进行调整。

    【讨论】:

      猜你喜欢
      • 2021-01-24
      • 1970-01-01
      • 2014-08-26
      • 2011-06-26
      • 1970-01-01
      • 2015-01-20
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多