title: Graphite as django web application returns 404 for all static resources
body: <p>DISCLAIMER: I know there's lots of questions here for <code>404</code> on static resources in <code>django</code>, but unfortunately none of it helps :(</p>
  
  <p>Problem: as stated in title, I got <code>404</code> response for all static resources in <code>graphite</code> web app.</p>
  
  <p>Here are some relevant config parts:</p>
  
  <p><strong>app_settings.py</strong>:</p>
  
  <pre><code>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',
  )
  </code></pre>
  
  <p><strong>settings.py</strong>:</p>
  
  <pre><code># 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 &gt;&gt; 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)
  </code></pre>
  
  <p><strong>local_settings.py</strong>:</p>
  
  <pre><code>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 *
  </code></pre>
  
  <p>Django version:</p>
  
  <pre><code>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.
  &gt;&gt;&gt; import django
  &gt;&gt;&gt; django.VERSION
  (1, 4, 14, 'final', 0)
  </code></pre>
  
  <p>Directories layout:</p>
  
  <pre><code>/opt/graphite/
      /webapp/
          /graphite/
          /content/ &lt;-- static files I want placed right here
  </code></pre>
  
  <p><code>/opt/graphite</code> is actually a symlink to another folder, if that matters.</p>
  
  <p>I got 404 errors for the urls like this:</p>
  
  <pre><code>http://my_host:9999/content/js/...
  http://my_host:9999/content/css/...
  </code></pre>
  
  <p>I have also tried <code>collectstatic</code> command with no success:</p>
  
  <pre><code>[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.
  </code></pre>
  
  <p>Django is started in the following way:</p>
  
  <pre><code>/usr/bin/django-admin runserver --pythonpath /opt/graphite/webapp --settings graphite.settings 0.0.0.0:9999 &amp;
  </code></pre>
  
  <p>Any help will be high appreciated.</p>
  
  <p>UPD: I have upgraded <code>django</code> to 1.5 and changed some paths:</p>
  
  <pre><code>STATICFILES_DIRS = (
      os.path.join(BASE_DIR, "content"),
  ) 
  
  STATIC_ROOT = ''
  STATIC_URL = 'static'
  </code></pre>
  
  <p>After that, <code>collectstatic</code> command finally worked and copied all files to <code>/opt/graphite/static</code> dir. I decided to try <code>DEBUG = True</code> and a miracle happened - finally I got all static files I wanted, but when I reverted it to default settings, <code>404</code> again.    </p>