2

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?

Juho Rutila
  • 2,316
  • 1
  • 25
  • 40
  • Did you call `python manage.py collectstatic`? – bdoubleu Nov 02 '18 at 11:20
  • Yes, it calls collectstatic automatically and the static files are in the 'static_collected' directory (I checked them by SSHing into the server) – Juho Rutila Nov 02 '18 at 11:27
  • Actually (don't know how I messed it) the files are not in the 'static_collected' dir. Apparently this has something to do with django-sass-processor not processing the scss files in collectstatic. – Juho Rutila Nov 02 '18 at 13:24

2 Answers2

1

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.

Daniele Procida
  • 1,477
  • 10
  • 27
0

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
Juho Rutila
  • 2,316
  • 1
  • 25
  • 40