django deployed site not loading static

321 views Asked by At

Perhaps I have miss understood something? I've deployed a site on my Amazon ec2 server, and it loads the page, but not the static. I've placed the "site_media" directory under the "www" directory like so: www/site_media/static etc. And when I inspect an image element on the site, it;s URL seams to point to the right direction as http://mysite.com/site_media/static/img/logo_text.jpg (mysite is replaced with my site url) but when I visit the page I get a 404 page not found. Since I have debug still turned on right now, I get a list of available URLS, the one pertaining to static is ^site\_media\/media\/(?P<path>.*)$ But then it says The current URL, site_media/static/img/logo_text.jpg, didn't match any of these.

Here is the static in my settings.py file:

STATIC_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "static")


STATIC_URL = "http://mysite.com/site_media/"


STATICFILES_DIRS = [
    os.path.join(PACKAGE_ROOT, "static"),

]


STATICFILES_FINDERS = [
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

And here is how the static is added into my main urls.py file:

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Let me know if you need any additional info!

1

There are 1 answers

1
hellsgate On BEST ANSWER

Shouldn't you be using STATIC_URL and STATIC_ROOT in your urlpattern rather than MEDIA_URL and MEDIA_ROOT?

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)