![](/img/trans.png)
[英]ModuleNotFoundError: No module named 'backend' in django-admin
[英]ModuleNotFoundError: No module named 'mysite' when try to call django-admin
當我在終端中運行命令django-admin collectstatic
,出現以下錯誤:
ModuleNotFoundError: No module named 'mysite'
它甚至出現在列表的末尾django-admin
commands help
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: No module named 'mysite').
myProject
|
+----mysite
| |
| +----settings.py
| +----wsgi.py
| +----urls.py
|
|
+----todo (app)
|
+----accounts(app)
|
+----myvenv
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
WSGI_APPLICATION = 'mysite.wsgi.application'
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()
而不是django-admin collectstatic
使用這個命令
python manage.py collectstatic
請參閱此主題https://docs.djangoproject.com/en/3.1/ref/django-admin/#django-admin-and-manage-py
在 myside 目錄和 myproject 中創建__init__.py
文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.