Monday, October 22, 2012

Re: My page cound not load image, help!

I use ImageField(with upload_to = 'photos') to receive user-uploaded images. And in my template, I want to use <img src="{{ object.image.url }}" />(image is the object of ImageField) to display them. However, images can't be displayed. I think it's not about static files. If it is, what's the use of ImageField's url property.

在 2012年10月22日星期一UTC+8下午7时46分04秒,Joel Goldstick写道:
On Mon, Oct 22, 2012 at 6:00 AM, Dae James <daed...@126.com> wrote:
> The returned html code by my app is : <img src="photos/image.jpg" />
> The "image.jpg" file is in "project_dir/photos/" directory. PS: project_dir
> is my django project's root directory.
>
> So why the image could not be loaded. Please help~
> Thank you~
>
Because your image is not in the directory  that your html file shows.
 Go to the django documentation and try to understand static files.

> ________________________________
> Dae James

--
Joel Goldstick

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

No comments:

Post a Comment