我收到服务器错误,因为django即使在文件夹中也可以看到它,却找不到我的静态文件之一:
ValueError: Missing staticfiles manifest entry for 'staticfiles\assets\img\icons\theme\communication\adress-book-2.svg'
我在静态和静态文件中都看到该文件位于此文件夹中
static\assets\img\icons\theme\communication\
模板中的文件路径:
{% load static %}
<img src="{% static 'assets\img\icons\theme\communication\adress-book-2.svg' %}" alt="Confirmation Icon" class="icon bg-primary" data-inject-svg="data-inject-svg">
运行collectstatic
无效。有什么想法吗?
谢谢!
编辑:忘记添加settings.py静态设置:
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
DEBUG_PROPAGATE_EXCEPTIONS = True
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
答案 0 :(得分:0)
首先,您应该删除以下行:
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
然后您可以保留前两行:
STATIC_ROOT = os.path.join(BASE_DIR, 'Folder') #either put static or staticfiles and then remove the other folder
STATIC_URL = '/static/'