~/Untitled.html
Getting your images to display on Django.
You might have found it a bitch to get your images ( background, etc ) to display on django – even after setting MEDIA_ROOT and MEDIA_URL to the seemingly proper values.
Here’s how you actually do it –
go to your urls.py and add this urlconf pattern at the end :
(r’^site_media/(?P<path>.*)$’, ‘django.views.static.serve’,{ ‘document_root’: ‘/home/tnevzn/media/’ })
so, your pics should now reside under /home/tnevzn/media.
and to access your pics , e.g: <body background="/site_media/a.jpg"> , where a.jpg resides in /home/tnevzn/media.
That’s all. No values in MEDIA_URL, MEDIA_ROOT or the like in settings.py are necessary – leave them blank.
Holy fuck – I can’t believe this wasn’t there ANYWHERE on the fuckin’ net. I wasted like 30 minutes doubting my cognitive skills by reading all the sites that said the same thing – MEDIA_ROOT and MEDIA_URL.
Damnit. You gotta fend for yourself
- anonymouscowherd