Elwin
Elwin

Reputation: 11

django-admin and static files

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

Upvotes: 1

Views: 487

Answers (1)

kartheek
kartheek

Reputation: 6694

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 :)

Upvotes: 1

Related Questions