On Saturday, March 19, 2011 12:54:22 PM UTC, Vladimir wrote:
>
> Daniel, I understand that's a wrong idea to mix files of different 
> nature in one directory. I only showed that one and the same simple 
> (?) configuration: index.html plus image file does works when I call 
> index.html directly and doesn't work when I call it in Django style. 
> Of cource, this is a result of my bad skills. Would you be so kind to 
> point me on my mistake?


Because when you open the file directly in your browser, it's not being 
*served*, your browser is simply reading it off the local disk. So it can 
read the image in the same location.

But if you're going through Django, you're expecting Django to serve the 
view, which renders the template. Normally this will be over the internet, 
which of course can't just read any old file - it has to be *served* to you 
at a URL. So you need to actually have a URL for the image, and something 
set up to serve it. That is what people have been pointing you to in this 
thread.

So you put the image in the media directory. Then, you set up (for 
development only) the static serve view in your urls.py, as you have been 
shown. Then you refer to the file in the template using MEDIA_URL, so your 
browser knows where to request the image.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to