While deploying a Django app. I am having problem with static files. I am having JS and CSS files in static directory. But browser is not able to find those files. I am having same files and settings on local machine that is ubuntu same as server OS, and have working on local. Although it has same settings but I am pasting that static directory and files setting below.
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(ROOT_PATH,'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS =(
os.path.join(ROOT_PATH,'static'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
Here root path in above code is defined before that is :
import os
#from django.contrib.sites.models import Site
ROOT_PATH = os.path.dirname(__file__)
I am using mod_wsgi with apache2, in my understanding it should find the files when it is loading /somefoldername then browser should go in that directory but didn't get where is problem. To know about environment and wsgi settings e.t.c. I am following here is question in which I posted my wsgi file details and way it is working: 500 server error on Django site after shifting to server
I am many time having issues while finding apps and other templates and modules etc. even in syncdb commmand on server, for templates I appended root path and it started working also added project path in wsgi file but still that static files issue is not solved.