[Answer]-New Django App MEDIA_URL pathing incorrect

1👍

Thanks everyone for the help! It turns out this is just a mistake I made 🙁 Very interesting consequences though.

I noticed something funny in the logs about A (% csrf_token %) was used in a template, but the context did not provide the value. This is uaually caused by not using RequestContext.

Lo and behold, in my views.py this line was incorrect:
return render_to_response('foo_track/foo_track_show.html',{'access':access})

it should have had the RequestContext(request) as well like this:
return render_to_response('foo_track/foo_track_show.html',{'access':access},RequestContext(request))

And now everything works. Sheesh!

0👍

I believe you have to explicitly define a “site_media” url in your urls.py

Like so:

Add this to imports

from django.conf import settings

And this to your urlpatterns:

url(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {
        'document_root': settings.MEDIA_ROOT}))

Otherwise, Django will assume you are using a different web server to serve the static content. Which, by the way, is a great idea. Here is an article on serving static content with Apache and mod_wsgi

Leave a comment