Имя приложения wsgi 'BASE_DIR' не определено - PullRequest
0 голосов
/ 27 мая 2020

Я развернул приложение django на pythonanywhere.com. Я вижу эту ошибку. Я много искал, но ничего не нашел. Я застрял с 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/

1 Ответ

1 голос
/ 27 мая 2020

Похоже, что BASE_DIR не определено в файле настроек. Ниже в некоторой степени зависит от макета вашего проекта. Но это то, что я использую в своих проектах.

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

Его можно адаптировать, если вы поделитесь своей файловой структурой.

...