Help please find the error.

I want to display the picture glad.jpg , but Django does not find it.

HTML registration.html

 <!DOCTYPE html> <img src="static/glad.jpg" alt=img> 

settings.py

 STATIC_URL = '/static/' PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = BASE_DIR 

Browser

Browser

GET http://127.0.0.1:8000/static/glad.jpg 404 (Not Found) Browser Console GET http://127.0.0.1:8000/static/glad.jpg 404 (Not Found)

Project tree screen

enter image description here

I have no idea why it doesn’t work, I read / tried everything.

Did the same

 <!DOCTYPE html> {% load static %} <img src="{% static "glad.jpg" %} " alt="img"> 

, but nothing heals it. Even the pycharm sees the image. Collectstatic did a bunch of times. Help me please!

    1 answer 1

    It is better to leave the last option:

     <!DOCTYPE html> {% load static %} <img src="{% static "glad.jpg" %} " alt="img"> 

    Your folder architecture is a bit confusing. Perhaps you should put all the static in some particular place and point the way to this place in STATICFILES_DIRS , which should solve your problem.

    Example from documentation :

     STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] 

    You can read about statics here .

    • And will this drawing be tightened from this static folder? - Valery Mikheenko
    • The statics will be pulled from all the folders specified in STATICFILES_DIRS - Sergey Chabanenko
    • Earned! THANK! 4 hours and finally decided! Good luck to you! - Valery Mikheenko