python - Images into a template in Django 1.8 -
im using python 3.4, , django 1.8
im trying display image in django template! im using next code:
in settings:
static_url = '/static/' staticfiles_dir = (r'c:\users\cesaralfonso\desktop\docbook\cuenta\static')
in template:
{% load staticfiles %} <img src="{% static "cuenta/celeste.jpg" %}" alt="my image"/>
but doesn't work! image celeste.jpg saved in static files specified direction! help!
your staticfiles_dir should this:
staticfiles_dir = ('c:/users/cesaralfonso/desktop/docbook/cuenta/static',)
note slashes switched \
/
, r'
removed , added comma @ end. r'text'
means raw string:
such strings called raw strings , use different rules interpreting backslash escape sequences
and comma @ end makes tuple.
update:
note these paths should use unix-style forward slashes, on windows (e.g. "c:/users/user/mysite/extra_static_content").
from django docs
Comments
Post a Comment