Static image not getting displayed.

132 views
Skip to first unread message

Sandip Nath

unread,
Apr 2, 2019, 2:00:13 PM4/2/19
to Django users
Downloaded an image of Django Reinhardt and saved it in static/images folder as django.jpeg. In the settings.py file created a variable STATIC_DIR and assigned it os.path.join(BASE_DIR, 'static') and again assign this variable to STATICFILES_DIR and kept the STATIC_URL as "/static/". In the index.html written that:
<img src="{% static 'images/django.jpeg' %}" alt='django reinhardt' /> 

But after doing all this I am getting only the text of alt and no image. Where I am wrong? Please help.

Agbonxoft Prince

unread,
Apr 2, 2019, 2:37:01 PM4/2/19
to django...@googlegroups.com
Try loading static , if it's not loaded
{% load static %} in the HTML page


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bbaac132-6d24-43a3-8278-fe5878c0b694%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ing.Daniel Bojorge

unread,
Apr 2, 2019, 3:44:11 PM4/2/19
to django...@googlegroups.com
See the development tools and look what path is it?

So, put STATIC_URL = '/static/' in your settings.py and 
{% load static %} in the first link of your template.


Mi Blog
Nicaragua

"Si ustedes permanecen unidos a mí, y si permanecen fieles a mis enseñanzas, pidan lo que quieran y se les dará.
(Juan 15:7 DHH)
Bendito el varón que se fía en el SEÑOR, y cuya confianza es el SEÑOR.
(Jeremías 17:7 RV2000)



Chetan Ganji

unread,
Apr 2, 2019, 3:46:44 PM4/2/19
to django...@googlegroups.com
{% load static %} in the first link of your template.

You have below code
<img src="{% static 'images/django.jpeg' %}" alt='django reinhardt' /> 

The line should be 
<img src="{% static 'django.jpeg' %}" alt='django reinhardt' /> 


Regards,
Chetan Ganji
+91-900-483-4183


Reply all
Reply to author
Forward
0 new messages