1

I'm new to django and recently I'm following this tutorial to write a todo-list app. In part 2 I should customize the admin's change_list template and add an image into it. At first I use

<img class='btn' src='static/img/on.png'>

but it turns out to be invalid. Can anybody figure out what's the problem is? Thanks a lot.

Here is my folder structure

todo-list
   todo-app
        img
          ----on.png
          ----off.png
   templates
        admin
           ----change_list.html
   todo-list
Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175
Elwin
  • 11
  • 1

1 Answers1

1

you can't access the static file( images, css, js ) directly in django

to serve the static files you need to use {{ MEDIA_URL }} or {{STATIC_URL}} for that How do I include image files in Django templates?, and this link

this will helps u :)

Community
  • 1
  • 1
kartheek
  • 6,434
  • 3
  • 42
  • 41