Graphite as a django web application returns 404 for all static resources

DISCLAIMER: I know that there are many questions for 404static resources in django, but, unfortunately, none of this helps :(

Problem: as indicated in the header, I got a response 404for all static resources in the web application graphite.

Here are some relevant parts of the configuration:

app_settings.py

INSTALLED_APPS = (
  'graphite.metrics',
  'graphite.render',
  'graphite.browser',
  'graphite.composer',
  'graphite.account',
  'graphite.dashboard',
  'graphite.whitelist',
  'graphite.events',
  'graphite.url_shortener',
  'django.contrib.auth',
  'django.contrib.sessions',
  'django.contrib.admin',
  'django.contrib.contenttypes',
  'django.contrib.staticfiles',
  'tagging',
)

settings.py

# Defaults for these are set after local_settings is imported
STATIC_ROOT = ''
STATIC_URL = ''

...

## Load our local_settings
try:
  from graphite.local_settings import *  # noqa
except ImportError:
  print >> sys.stderr, "Could not import graphite.local_settings, using defaults!"

...

STATICFILES_DIRS = (
    join(WEBAPP_DIR, 'content'),
    "/opt/graphite/webapp/content/",
)

if not STATIC_ROOT:
  STATIC_ROOT = join(GRAPHITE_ROOT, 'static')

...

# Handle URL prefix in static files handling
if URL_PREFIX and not STATIC_URL.startswith(URL_PREFIX):
    STATIC_URL = '/{0}{1}'.format(URL_PREFIX.strip('/'), STATIC_URL)

local_settings.py

STATIC_ROOT = '/opt/graphite/webapp/content/'
STATIC_URL = '/content/'

STATICFILES_DIRS = (

#    os.path.join(BASE_DIR, "static"),
#    os.path.join(BASE_DIR, "content"),
    "/opt/graphite/webapp/content/",

)  

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

...

from graphite.app_settings import *

Django version:

Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 4, 14, 'final', 0)

Reference layout:

/opt/graphite/
    /webapp/
        /graphite/
        /content/ <-- static files I want placed right here

/opt/graphite actually a symlink to another folder, if that matters.

I have 404 errors for such URLs:

http://my_host:9999/content/js/...
http://my_host:9999/content/css/...

I also tried the command collectstaticwithout success:

[root@myserver graphite]# pwd
/opt/graphite/webapp/graphite
[root@myserver graphite]# python manage.py collectstatic
Could not import graphite.local_settings, using defaults!
Unknown command: 'collectstatic'
Type 'manage.py help' for usage.
[root@myserver graphite]# django-admin collectstatic --noinput --settings=graphite.settings
Unknown command: 'collectstatic'
Type 'django-admin help' for usage.
[root@myserver graphite]# python manage.py collectstatic --noinput --settings=graphite.settings
Unknown command: 'collectstatic'
Type 'manage.py help' for usage.

Django starts as follows:

/usr/bin/django-admin runserver --pythonpath /opt/graphite/webapp --settings graphite.settings 0.0.0.0:9999 &

Any help would be greatly appreciated.

UPD: django 1.5 :

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "content"),
) 

STATIC_ROOT = ''
STATIC_URL = 'static'

collectstatic - /opt/graphite/static dir. DEBUG = True - , , , , 404 .

+4
2

, DEBUG = True . , django dev: DEBUG = False django ?

, dev :

  • django 1.5;
  • STATIC_ROOT '' ( Graphite);
  • STATICFILES_DIRS;
  • python manage.py collectstatic --pythonpath=/opt/graphite/webapp
+2

-, , Django, ?

- Django >= 1.4, collectstatic.

collectstatic pythonpath, - python manage.py collectstatic --pythonpath=/opt/graphite/webapp.

Collectstatic , /opt/graphite/webapp/content. , 404s , , - webapp (, pythonpath).

+2

All Articles