Image won\'t load. I see o broken image icon. I use the static tag. I also tried giving the absolute path and never worked.I used the alt tag but still i can only see the br
check you static path setting in setting.py file
STATICFILES_DIRS = ( '/PATH/OF/YOUR/STATIC/DIRECTORY', )
if your static directory name is "static" then your path should be '/path-before-static/static' and you static URL should be.
STATIC_URL = '/static/'
your images should be within the static folder .../static/img/...jpg
In your template should be like this.
{% load staticfiles %} {% static 'img/demo.jpg' %} or "{{ STATIC_URL }}img/demo.JPG"
change setting.py file with This code
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
]
Are you in a production or development environment?
Can you access the /static/images/logo.png by typing it into the browser?
When in development, where debug is on I add this to the end of the urls.py file:
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)
See here: https://docs.djangoproject.com/en/1.5/ref/contrib/staticfiles/#other-helpers
Change:
{% load static %} {# loads static tag #}
to this:
{% load static from staticfiles %}
{% load static %} {# loads static tag #}
<div id="header">
{% block header %}
<img src="{% static 'images/logo.png' %}" alt="alternative text" />
#check your quotes inside image tag.
{% endblock %}
</div>