0

I added the following lines in my settings.py file:

STATIC_URL = '/static/' STATICFILES_DIR = [ os.path.join(BASE_DIR,"static"), ] STATIC_ROOT = os.path.join(BASE_DIR,"static") 

Then I edited my HTML file to use {% load static %} and <img src="{% static 'static/myapp/images/ABC.png' %}" alt="">, but still I am not able to see the ABC.png pic on my webpage. Can someone please help?


Screenshots of .py files: Screenshots of .py files

1 Answer 1

1

The issus is that you are incorrectly requesting the asset, use {% static 'myapp/images/ABC.png' %} instead. I suppose that you have the following structure in your app:

myapp static myapp images ABC.png templetes views.py ... 

As you can see, is not necessary to add the name of your statics directory. The path is relative to the static folder of any of your apps in your project.

Sign up to request clarification or add additional context in comments.

2 Comments

Static is not inside the myapp it is outside. and this solution is not working
Just using STATIC_URL = '/static/' should work. You should have the static folder inside your apps instead your project, you can have one static folder by each app and the path you use in the templates is relative to your static folders. try running python manage.py collectstatic

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.