我确实在服务器上安装了django。 不是将应用程序安装在django项目文件夹旁边,而是将它们安装在django项目文件夹中。(我将它们放在settings.py
和wsgi.py
旁边)
这是django项目的结构:
BaseFile
|__django (Project File)
| |___administrator (App)
| | |___ views.py
| | |___ urls.py
| | |___ ...
| |
| |___blog (App)
| | |___ views.py
| | |___ urls.py
| | |___ ...
| |
| |___ __init__.py
| |___ settings.py
| |___ urls.py
| |___ wsgi.py
|
|___ env
|___ manage.py
|___ media
|___ static
|___ templates
这是我的settings.py
:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# MY APPS:
'administrator.apps.AdministratorConfig',
'blog.apps.BlogConfig',
]
当我想makemigrations
时出现此错误:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "BaseFile/env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "BaseFile/env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "BaseFile/env/lib64/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "BaseFile/env/lib64/python3.6/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "BaseFile/env/lib64/python3.6/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'administrator'
我的代码有什么问题?