1

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).

fpghost
  • 2,834
  • 4
  • 32
  • 61
  • What is your STATIC_URL and MEDIA_URL? Also: why are you hardcoding URL to static file instead of using `{% static %}` tag? – GwynBleidD Aug 23 '15 at 13:50
  • I'm not hardcoding it, the css link element was generated by `{% stylesheet 'bootstrap' %}` of django-piplines. I was just showing the output the browser sees (i.e. that when pipelines enabled, it is indeed looking for the correct compressed css). As for `STATIC_URL` and `MEDIA_URL` they are `/site_media/static/` and `/site_media/media/` respectively (things work when `PIPELINES_ENABLED=True` is not forced. – fpghost Aug 23 '15 at 13:57
  • @fpghost Did you solve it? I have similar problem – user3595632 Nov 29 '16 at 15:41

0 Answers0