简体   繁体   中英

Divio Live server not serving the static files when DEBUG=False

I am running a website in Divio Cloud. My Test server serves the static files fine but my Live server gives 404. When I switch DEBUG to True on the Live server it starts serving the static files fine.

When the Live server starts, it has this in the log:

[uwsgi-static] added mapping for /static/ => /app/static_collected

Shouldn't that take care of serving the static files correctly?

--edit-- More info. I actually didn't have any "normal" static files. I added a static file using {% static %} and it is working! The files that are not working are collected with django-sass-processor and django-compressor. I have in settings.py:

STATICFILES_FINDERS.extend([
    'compressor.finders.CompressorFinder',
    ])

Shouldn't this only affect when the files are collected?

I think the issue is most likely in the fact that you are using Django Compressor. There are various different ways in which to use Django Compressor.

In its documentation, please see Offline Compression . This is what you need for it to work on Divio Cloud.

For future reference:

In Divio environment to get the compressor based processors (in this case it was django-sass-processor) to work is add something along following lines in the end of the Dockerfile:

 RUN DJANGO_MODE=build python manage.py compilescss

# <STATIC> 
RUN DJANGO_MODE=build python manage.py collectstatic --noinput
# </STATIC>

# Remove the css files in development environments (in Live they
# are already collected)
RUN DJANGO_MODE=build python manage.py compilescss --delete-files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM