Django cannot find contents of static/
Question: I'm trying to deploy an application to Heroku, but it cannot find my JS/CSS
files.

Here's my settings.py

# settings.py

    
    
    """
    Django settings for the MyApp project.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/1.7/topics/settings/
    
    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/1.7/ref/settings/
    """
    
    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    import os
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = SUPER SECRET
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = False
    
    TEMPLATE_DEBUG = DEBUG
    
    ALLOWED_HOSTS = []
    
    
    # Application definition
    
    INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'debug_toolbar',
        'rest_framework',
        'compressor',
        'authentication',
    )
    
    MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )
    
    ROOT_URLCONF = 'MyApp.urls'
    
    WSGI_APPLICATION = 'MyApp.wsgi.application'
    
    
    # Database
    # https://docs.djangoproject.com/en/1.7/ref/settings/#databases
    
    import dj_database_url
    
    DATABASES = {
        'default': dj_database_url.config(
            default='sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3')
        )
    }
    
    # Internationalization
    # https://docs.djangoproject.com/en/1.7/topics/i18n/
    
    LANGUAGE_CODE = 'en-us'
    
    TIME_ZONE = 'UTC'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    
    
    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/1.7/howto/static-files/
    
    STATIC_URL = '/static/'
    STATIC_ROOT = 'staticfiles'
    
    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, 'dist/static'),
        os.path.join(BASE_DIR, 'static'),
    )
    
    STATICFILES_FINDERS = (
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        'compressor.finders.CompressorFinder',
    )
    
    COMPRESS_ENABLED = True
    
    TEMPLATE_DIRS = (
        os.path.join(BASE_DIR, 'templates'),
    )
    
    REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': (
            'rest_framework.authentication.SessionAuthentication',
        )
    }
    
    # Honor the 'X-Forwarded-Proto' header for request.is_secure()
    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
    
    # Allow all host headers
    ALLOWED_HOSTS = ['*']
    
    AUTH_USER_MODEL = 'authentication.Account'
    
    if not DEBUG:
        # Parse database configuration from $DATABASE_URL
        import dj_database_url
        DATABASES['default'] =  dj_database_url.config()
    
        # Enable Connection Pooling
        DATABASES['default']['ENGINE'] = 'django_postgrespool'
    
    
        # Simplified static file serving.
        # https://warehouse.python.org/project/whitenoise/
        STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
    
    
        # Honor the 'X-Forwarded-Proto' header for request.is_secure()
        SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
    

Here's the file containing CSS that I want to serve:

# /static/templates/stylesheets.html

    
    
    {% load compress %}
    {% load static %}
    
    {% compress css %}
    <link rel="stylesheet" type="text/css" href="{% static "bower_components/bootstrap/dist/css/bootstrap.css" %}" />
    <link rel="stylesheet" type="text/css" href="{% static "bower_components/bootstrap-material-design/dist/css/material.css" %}" />
    <link rel="stylesheet" type="text/css" href="{% static "bower_components/bootstrap-material-design/dist/css/ripples.min.css" %}" />
    <link rel="stylesheet" type="text/css" href="{% static "bower_components/ngDialog/css/ngDialog.css" %}" />
    <link rel="stylesheet" type="text/css" href="{% static "bower_components/ngDialog/css/ngDialog-theme-default.css" %}" />
    
    <link rel="stylesheet" type="text/css" href="{% static "lib/snackbarjs/snackbar.min.css" %}" />
    
    <link rel="stylesheet" type="text/css" href="{% static "stylesheets/styles.css" %}" />
    {% endcompress %}
    

Is there something super wrong with my `settings.py`?

`/static/` exists in the root of my directory and does contain all of the
files in the HTML file.

If more information is needed, please let me know.


Answer: Django won't serve static files when `debug` is `False`, because the view is
inefficient and potentially insecure, therefore you have to config your
webserver. See "Deploying static files" in Django manual.

