0

Django cant find jpg. It is in the same folder as my html. Tried everything i could, I have no idea why this is happening. I am using index.html. Tried different files, different file paths, different file types...etc. File isnt corrupted, program works fine for everything else.

File Locations

<div>
  <img src="portBack.jpg" alt="">
</div>

1 Answer 1

1

Django handles static files in a different way. You can't put url directly in the file.

Firat of all you need to save you image file inside the static folder in the app. After that you need add following line in settings.py file.

STATIC_URL = '/static/'

And following in html file. {% load static %} <img src="{% static "my_app/example.jpg" %}" alt="My image">

For more information, please check official documentation.

https://docs.djangoproject.com/en/3.1/howto/static-files/

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.