Testing django-pipelines on a dev machine

309 Views Asked by At

I would like to test django-pipelines during development (i.e. on a development machine with only django runserver and no production webserver).

Normally during development Django serves static files so long as DEBUG=True, but not so if DEBUG=False. Thus without a proper webserver it seems I need to keep DEBUG=True in my settings. Usually django-pipelines does not do compression if DEBUG=True, but it can be forced supposedly by setting PIPELINE_ENABLED=True. Thus my assumption was that by setting

 # local_settings.py
 DEBUG = True   # keep serving static files
 PIPELINE_ENABLED = True   # force django-pipelines to operate 

I would be in a position to test django-pipelines on my dev machine. I also added

# urls.py
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

I ran a collectstatic and the output css file was copied over to my STATIC_ROOT (myproj/static_media/static/css/out.css). However Django is not serving this css file. The HTML looks for it

<link href="/site_media/static/css/out.css" rel="stylesheet" type="text/css" media="screen,projection">

but it 404s.

Nevertheless the minute I change PIPELINE_ENABLED=False (still DEBUG=True etc) and then manually navigate to /site_media/static/css/out.css Django serves up the file.

Why isn't this setup working and how can I test django-pipelines on a local development machine with nothing but runserver? (this is django 1.8 by the way).

0

There are 0 best solutions below