I have a django project that works fine with the embedded server, but when I try to use it on Apache/mod_wsgi, the static files of the admin pages (/static/admin/css) are not found (404). Here are my settings:
MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = '/var/www/wsgi/myproject/static'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS = ()
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"socialauth.context_processors.facebook_api_key",
'django.core.context_processors.media',
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
"django.core.context_processors.static",
)
ROOT_URLCONF = 'myproject.urls'
TEMPLATE_DIRS = ('/var/www/wsgi/myproject/templates',)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'myproject.myapp',
)
I also tried running
sudo python ./manage.py collectstatic
but with no luck.
What does you apache virtualhost config look like? You should include an
Aliasdirective for theSTATIC_ROOTpath.Something along these lines:
As you’ve written, you would need to run
./manage collectstaticeach time you want to deploy new static files in production.