Python django.core.exceptions.impropertlyconfigured:You';在未将静态根设置设置为文件系统路径的情况下重新使用staticfiles应用程序

Python django.core.exceptions.impropertlyconfigured:You';在未将静态根设置设置为文件系统路径的情况下重新使用staticfiles应用程序,python,django,git,heroku,Python,Django,Git,Heroku,当我运行git push heroku master时,它指出我的静态根目录配置不正确(错误:raise INPROPERLYCONFIGURED(“您使用的是staticfiles应用程序,但没有将静态根目录设置为文件系统路径”)。我设置了静态根目录,如视频教程所示 设置.py .gitignore # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so #

当我运行git push heroku master时,它指出我的静态根目录配置不正确(错误:raise INPROPERLYCONFIGURED(“您使用的是staticfiles应用程序,但没有将静态根目录设置为文件系统路径”)。我设置了静态根目录,如视频教程所示

设置.py

.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
<<<<<<< HEAD
=======
pip-wheel-metadata/
>>>>>>> 661353800061e4584535573f7e8b813cb01040c2
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
<<<<<<< HEAD
cover/
=======
>>>>>>> 661353800061e4584535573f7e8b813cb01040c2

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
<<<<<<< HEAD
.pybuilder/
=======
>>>>>>> 661353800061e4584535573f7e8b813cb01040c2
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
<<<<<<< HEAD
#   For a library or package, you might want to ignore these files since the code is
#   intended to run in multiple environments; otherwise, check them in:
# .python-version
=======
.python-version
>>>>>>> 661353800061e4584535573f7e8b813cb01040c2

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
<<<<<<< HEAD

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

/.idea/
.idea/workspace.xml
=======
>>>>>>> 661353800061e4584535573f7e8b813cb01040c2
#字节编译/优化/DLL文件
__pycache__/
*.py[cod]
*$py.class
#C扩展
*.那么
#分发/包装
python
建造/
产卵/
距离/
下载/
蛋/
.鸡蛋/
解放党/
lib64/
零件/
sdist/
变量/
轮子/
>661353800061e4584535573f7e8b813cb01040c2
共享/python控制盘/
*.鸡蛋信息/
.installed.cfg
*.鸡蛋
显示
#PyInstaller
#通常,这些文件是由模板中的python脚本编写的
#在PyInstaller构建exe之前,将日期/其他信息注入其中。
*.舱单
*.规格
#安装程序日志
pip-log.txt
pip-delete-this-directory.txt
#单元测试/覆盖报告
htmlcov/
.毒素/
.氮氧化物/
.保险范围
.保险范围*
隐藏物
nosetests.xml
coverage.xml
*.掩护
*.py,掩护
.假设/
.pytest_缓存/
>661353800061e4584535573f7e8b813cb01040c2
#翻译
*莫先生
*波特先生
#Django stuff:
*.日志
本地_settings.py
db.sqlite3
db.sqlite3-journal
#烧瓶材料:
实例/
.webassets缓存
#脏东西:
.痒
#斯芬克斯文献
文档/_构建/
#PyBuilder
>661353800061e4584535573f7e8b813cb01040c2
目标/
#Jupyter笔记本
.ipynb_检查点
#伊皮顿
配置文件\u默认值/
ipython_config.py
#皮恩夫
>661353800061e4584535573f7e8b813cb01040c2
#佩彭夫
#根据pypa/pipenv#598,建议在版本控制中包括Pipfile.lock。
#但是,在协作的情况下,如果具有特定于平台的依赖项或依赖项
#由于没有跨平台支持,pipenv可能会安装不起作用或不起作用的依赖项
#安装所有需要的依赖项。
#Pipfile.lock
#PEP 582;由例如github.com/David-OConnor/pyflow使用
__pypackages__/
#芹菜
芹菜节拍
芹菜
#SageMath解析文件
*圣人
#环境
环境署署长
文夫先生
环境/
文夫/
环境/
环境贝克/
文沃贝克/
#Spyder项目设置
.spyderproject
.间谍项目
#Rope项目设置
.ropeproject
#mkdocs文档
/场地
#麦皮
.mypy_缓存/
.dmypy.json
dmypy.json
#火堆式检查器
派尔先生/
>661353800061e4584535573f7e8b813cb01040c2

将静态根目录添加到settings.py中。 您还必须将静态目录路径添加到根目录的url.py文件中,其中包含settings.py文件

from django.views.static import serve

path('static/<path:path>/', serve, {'document_root': settings.STATIC_ROOT, }),
来自django.views.static导入服务的

路径('static/',serve,{'document_root':settings.static_root,}),

您需要这样命名这些变量(并记住创建相应的文件夹):


请显示完整的回溯。您将学习什么教程?请注意,
.gitignore
(在
部分)中存在合并冲突,你应该整理一下。我正在学习correy schaffer的教程。我该怎么做。我添加了一些scrren快照,你能检查一下吗?当你运行
git push heroku master
时,仍然没有显示完整的错误消息。我认为你没有提供足够的信息让我们帮助你。如果你链接到如果你陷入困境,那么它可能会有所帮助,但我认为没有人会开始搜索correy schaffer教程,并试图追踪你可能陷入困境的地方。
.gitignore
中的合并冲突是一个次要问题,它与静态文件问题无关。该文件不应包含
de>====等号行,这样您就可以删除它们。合并冲突可能意味着您最终会丢失/重复行。因为它只是一个
.gitignore
文件,不太重要,但您应该尽量避免合并冲突,因为它们会破坏您的代码。我添加了错误截图,有点搞不清楚错误可能出现在哪里
from django.views.static import serve

path('static/<path:path>/', serve, {'document_root': settings.STATIC_ROOT, }),
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'staticfiles'), ]