Django collectstatic没有找不到管理媒体内容

时间:2015-06-15 06:39:22

标签: django collectstatic

我在Ubunutu上使用Virtualenv和Gunicorn等运行Django 1.8.2项目。出于某种原因,collectstatic没有获得管理媒体,但它确实可以在我的本地开发环境中使用osx。

我不确定问题的来源?是设置吗?但是为什么它可以在osx上运行而不在我的Ubuntu服务器上呢?

以下是我的设置:

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',
)

1 个答案:

答案 0 :(得分:5)

来自doc您必须添加

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

中的