My django application is working well on local server. But, when I deploy it on Heroku, the static files are not being served (getting a 404 error). Please help!
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = patterns('',
url(r'^$', 'product.views.home', name='home'),
url(r'^admin/', include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
static files settings:
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "static", "media")
STATIC_ROOT = os.path.join(BASE_DIR, "static", "static_root")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static", "static_dirs"),
)
WSGI file -
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "acton.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
try:
from dj_static import Cling
application = Cling(get_wsgi_application())
except:
pass