I have a Django deployment with Apache24 that was working as expected previously, with the django project name being "API_Materials". However, when I tried to make new migrations with
Код: Выделить всё
python manage.py makemigrationsКод: Выделить всё
(venv) C:\API\BD_API_Materials>python manage.py makemigrations
Traceback (most recent call last):
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\base.py", line 453, in execute
self.check()
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\base.py", line 485, in check
all_issues = checks.run_checks(
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\checks\urls.py", line 36, in check_url_namespaces_unique
if not getattr(settings, "ROOT_URLCONF", None):
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\conf\__init__.py", line 102, in __getattr__
self._setup(name)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\conf\__init__.py", line 89, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\conf\__init__.py", line 217, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Program Files\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 992, in _find_and_load_unlocked
File "", line 241, in _call_with_frames_removed
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'MaterialsAPI'
Debugging
First I tried going "back on time" with
Код: Выделить всё
git reset --hardКод: Выделить всё
makemigrationsКод: Выделить всё
makemigrationКод: Выделить всё
(venv) C:\API\BD_API_Materials>python manage.py makemigration
Traceback (most recent call last):
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\__init__.py", line 255, in fetch_command
app_name = commands[subcommand]
KeyError: 'makemigration'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\API\BD_API_Materials\manage.py", line 22, in
main()
File "C:\API\BD_API_Materials\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\core\management\__init__.py", line 262, in fetch_command
settings.INSTALLED_APPS
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\conf\__init__.py", line 102, in __getattr__
self._setup(name)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\conf\__init__.py", line 89, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\afonso.campos\Desktop\BD_API_Materials\API\venv\lib\site-packages\django\conf\__init__.py", line 217, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Program Files\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 992, in _find_and_load_unlocked
File "", line 241, in _call_with_frames_removed
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'MaterialsAPI'
Код: Выделить всё
INSTALLED_APPSКод: Выделить всё
settings.pyКод: Выделить всё
INSTALLED_APPS = [
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'API_Materials.apps.ApiMaterialsConfig',
'rest_framework',
'rest_framework.authtoken',
'django_extensions',
'drf_yasg',
'cryptographic_fields'
]
Observing the environment variables before the line which cause the error
Код: Выделить всё
settings.INSTALLED_APPSКод: Выделить всё
environ({
...
'VIRTUAL_ENV': 'C:\\Users\\afonso.campos\\Desktop\\BD_API_Materials\\API\\venv',
'DJANGO_SETTINGS_MODULE': 'MaterialsAPI.settings'
...
})
Код: Выделить всё
manage.pyLastly, this error doesn't occur when I test the project locally in a different environment.
Источник: https://stackoverflow.com/questions/781 ... n-apache24
Мобильная версия