当我在终端中运行命令django-admin collectstatic
时,出现以下错误:
ModuleNotFoundError: No module named 'mysite'
它甚至出现在列表django-admin
命令帮助的结尾
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()
答案 0 :(得分:0)
在myside目录和myproject中创建__init__.py
文件
答案 1 :(得分:0)
代替django-admin collectstatic
使用此命令
python manage.py collectstatic
请参阅本主题https://docs.djangoproject.com/en/3.1/ref/django-admin/#django-admin-and-manage-py