Search code examples
djangocollectstatic

Django collectstatic not does not find admin media content


Im running a Django 1.8.2 project on Ubunutu with Virtualenv and Gunicorn etc. For some reason collectstatic does not get the admin media, but it does work on my local dev environment on osx.

Im not sure where the problem comes from? Is it the settings? But why then does it work on osx and not on my Ubuntu server?

Here is my settings:

import os


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


SECRET_KEY = '123'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
SITE_ID = 1
ALLOWED_HOSTS = ['localhost', '127.0.0.1']

ADMINS = (

)

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'djcelery',
    'djangobower',

    'client',
    'billable',
    'recurring_invoice',
    'company',
    'app',

)

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',
    'django.middleware.security.SecurityMiddleware',
)

STATICFILES_FINDERS = (
    "django.contrib.staticfiles.finders.FileSystemFinder",
    'djangobower.finders.BowerFinder',
)

ROOT_URLCONF = 'stem.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'stem.wsgi.application'



DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

BOWER_COMPONENTS_ROOT = os.path.join(BASE_DIR, 'components')

import djcelery
djcelery.setup_loader()

CELERY_IMPORTS = ('recurring_invoice.tasks',)
BROKER_URL = "amqp://guest:guest@localhost:5672//"
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']


BOWER_INSTALLED_APPS = (
    'jquery',
    'underscore',
    'angular#1.3.16',
    'moment',
)

Solution

  • From doc You have to add

    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    

    in STATICFILES_FINDERS