Monday, October 22, 2012

Re: My page cound not load image, help!

Serve the image as a static file. in your settings.py file set the following:

STATIC_URL = '/static/'
STATICFILES_DIRS = ('/path/to/your/image/directory',) # Without a trailing slash

and then load your image as <img src="/static/image.jpg" />


On Mon, Oct 22, 2012 at 5:14 PM, Joel Goldstick <joel.goldstick@gmail.com> wrote:
On Mon, Oct 22, 2012 at 6:00 AM, Dae James <daedae11@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 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.




--
Thanks & Regards
----------------------------

Amyth [Admin - Techstricks]
Email - aroras.official@gmail.com, admin@techstricks.com
Twitter - @mytharora
http://techstricks.com/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment