在 Azure Web 应用程序上获取了我的 Django 项目,但是当我在 SSH 终端上调用时:
Python 管理.py 收集静态
它说复制了 252 个文件,但我的静态文件在我的模板上不可见,并且 wwwroot 中的静态文件夹是空的......这是我的 wwwroot 结构:
wwwroot
|---Myproject
|---manage.py
|---oryx-manifest.toml
|---hostingstart.html
|---static //With all my static files
├── myapp
│ ├── migrations
│ ├── __pycache__
│ ├── static
| | |---Images
| | | |--myimage.png
| | | |--myimage2.png
│ └── templates
这是我的settings.py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
('myapp', os.path.join(BASE_DIR, 'myapp', 'static')),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
知道为什么或者我做错了什么吗?Azure 收集的数据是否不同?
编辑> 当我访问我的网站时,我的图像不显示...我在模板上这样称呼它们:
{% load static %}
<img src="{% static 'Images/myimage.png' %}" /><br>
编辑2 /////
在 wwwroot 中确实创建了一个包含所有静态数据的文件夹,但是当我加载模板时它们没有显示,在 wen 控制台中,我收到 myimage.png 和 myimage2.png 的错误:
Failed to load resource: the server responded with a status of 404 (Not Found)