django-pipeline unable to serve assets

181 views
Skip to first unread message

Marcela Campo

unread,
Nov 3, 2014, 1:25:49 PM11/3/14
to django...@googlegroups.com
Hi, I am running into some issues configuring django-pipeline. It is compressing and creating the asset groups as expected when running collectstatic but then I get a 404 error when trying to load them in the app. I've been playing around with paths and settings and I cannot figure out why.

Using STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'  I get a good response from python manage.py findstatic <file relative path>  but still cannot load them in my webpage. These are my settings

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',  
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'pipeline', 
    'django_extensions',
    'widget_tweaks',
    'django.contrib.gis',
    'django_hstore',
    'registration',
    'ui',
)

# Static asset configuration
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'

STATICFILES_FINDERS = (
    'pipeline.finders.FileSystemFinder',
    'pipeline.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
    'pipeline.finders.CachedFileFinder',
)


PIPELINE_CSS = {
    'base': {
        'source_filenames': (
          'ui/css/bootstrap.min.css',
          'ui/css/adjust.css',
        ),
        'output_filename': 'ui/css/myapp_base.css',
    },
}

PIPELINE_JS = {
    'base': {
        'source_filenames': (
          'ui/js/jquery-1.11.0.min.js',
          'ui/js/js/bootstrap.min.js',
        ),
        'output_filename': 'ui/js/myapp_base.js',
    }
}


And in my templates:

{% load staticfiles %}
{% load compressed %}

{% compressed_js 'base' %}
{% compressed_css 'base' %}


When I run collectstatic I see under my staticfiles dir, the files ui/js/myapp_base.js and ui/css/myapp_base.css are being created, calling python manage.py findstatic ui/css/myapp_base.css works but I get a 404 in my webapp

If I use STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' I see also some extra files with random identifiers are being generated, but then I get a 404 when requesting those files (including random id) and in this case, findstatic also fails (if i look with the file including the random id in the name)

I am sure I am missing something but I just cannot figure this out. Does anyone have any pointers to this one?

Thanks
Marcela


Marcela Campo

unread,
Nov 3, 2014, 2:26:21 PM11/3/14
to django...@googlegroups.com
Replying to my own post... I finally realized what I was missing. Going back to the basics I realized I am trying this in dev with runserver instead of through nginx + gunicorn, so basically there was nothing serving the assets. It is working now.
Reply all
Reply to author
Forward
0 new messages