On Sun, Aug 23, 2009 at 3:54 PM, When ideas
fail<andrewkenyon...@gmail.com> wrote:
>
> Hello, i'm having a problem getting images to display so I was
> wondering if someone would be kind enough to help?
>
> I have my settings.py set up as follows (content is the folder where
> my static images are stored):
>
> MEDIA_ROOT = '/home/mysite/content/'
> MEDIA_URL = 'http://www.mysites.net/content/'
>
> Then my template is like so:
>
> <img src="{{ MEDIA_URL }}{{ object.post_img }}" />
>
> where object.post_img = imgs/newMessage.jpg
>
> but if i load the page up it doesn't appear. I checked the error log
> it says:
>
> File does not exist: /home/mysite/public_html/content, referer:
> http://www.mysite.net
>
> so it has added public_html to the path, how can i solve this issue?
>

By using the documented way to output the URL of a FileField / ImageField:

<img src="{{ object.post_img.url }}" alt="" />

Look here for more information:
http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield



Matthias

--~--~---------~--~----~------------~-------~--~----~
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