问题描述
编辑 05/02/2021 10:45
阅读其他帖子表明这个问题有很多可能的原因
如果有人可以帮助我解释 django_compressor 应该如何工作?
例如
清单文件被称为 staticfiles.json 是否正确?
这个文件没有路径是不正常的?
它应该包含哪些路径? ...
编辑 04/02/2021 14:00
我跑
python manage.py findstatic --verbosity 2 theme.scss
然后得到(下面),这意味着路径是正确的吗?
Found 'theme.scss' here:
/usr/src/app/static/theme.scss
Looking in the following locations:
/usr/src/app/static
编辑 04/02/2021 13:38
我提到使用 DEBUG = True 和 runserver 它可以工作
我的意思是我可以自定义引导程序
我可以在 /usr/src/app/static
中看到 staticfiles.json 但该文件不包含路径 {"paths": {},"version": "1.0"}
编辑 04/02/2021 13:04
在运行过程中,提到的日志
0 static files copied to '/usr/src/app/static'.
Found 'compress' tags in:
/usr/src/app/cafe/templates/cafe/table.html
...
但是我已经在 web 容器中进行了控制,并且静态文件在 /usr/src/app/static
处按预期可用(请参阅 docker-compose 文件)
我尝试使用 django_compressor et django libsass 在我的 Django 项目中使用 SCSS
堆栈:Django/Nginx/Postgresql/Docker 我已经配置了 2 个开发环境:dev 和 preprod
出现错误:valueerror: missing staticfiles manifest entry for 'theme.scss'
我不明白,因为它已经起作用了,但我尝试删除容器/图像/卷并重建我的所有项目,但出现此错误
我试过 DEBUG = True,STATIC_ROOT = 'static'...但没有任何效果
日志只会引发此错误
设置 -> preprod.py
- app
- core
- static
- bootstrap
- css
- js
- theme.scss
- Nginx
DEBUG = False
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,"static")
STATICFILES_FINDERS = [
'compressor.finders.CompressorFinder',]
COMPRESS_PRECOMPILERS = (
('text/x-scss','django_libsass.SassCompiler'),COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
LIBSASS_OUTPUT_STYLE = 'compressed'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesstorage'
)
entrypoint.preprod.sh
python manage.py collectstatic --no-input
python manage.py compress --force
docker-compose.preprod.yml
version: '3.7'
services:
web:
restart: always
container_name: web
build:
context: ./app
dockerfile: Dockerfile.preprod
restart: always
command: gunicorn core.wsgi:application --bind 0.0.0.0:8000
volumes:
- app_volume:/usr/src/app
- static_volume:/usr/src/app/static
- media_volume:/usr/src/app/media
expose:
- 8000
env_file:
- ./.env.preprod
depends_on:
- db
- redis
healthcheck:
test: ["CMD","curl","-f","http://localhost:8000/"]
interval: 30s
timeout: 10s
retries: 50
redis:
container_name: redis
image: "redis:alpine"
celery:
container_name: celery
build:
context: ./app
dockerfile: Dockerfile.preprod
command: celery -A core worker -l info
volumes:
- app_volume:/usr/src/app
env_file:
- ./.env.preprod
depends_on:
db:
condition: service_started
web:
condition: service_healthy
redis:
condition: service_started
celery-beat:
container_name: celery-beat
build:
context: ./app
dockerfile: Dockerfile.preprod
command: celery -A core beat -l info
volumes:
- app_volume:/usr/src/app
env_file:
- ./.env.preprod
depends_on:
db:
condition: service_started
web:
condition: service_healthy
redis:
condition: service_started
db:
container_name: db
image: postgres:12.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
- app_volume:/var/lib/postgresql/backup
env_file:
- ./.env.preprod.db
Nginx:
container_name: Nginx
build: ./Nginx
restart: always
volumes:
- static_volume:/usr/src/app/static
- media_volume:/usr/src/app/media
ports:
- 1340:80
depends_on:
web:
condition: service_healthy
volumes:
postgres_data:
static_volume:
media_volume:
app_volume:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)