Search code examples
djangodjango-templatesdjango-staticfilesdjango-static

Django, not able to load image, but css is loaded


I m able to load css file based on the tutorial provided by djangoproject but images are not getting loaded. Here is the file structure: appname/static/ mess/ img/ burger.jpg

Here is the login.html file where I m trying to load the image.

`<html>
 <head>
     <title>Login | Mess @ IIIT Sri City</title>
     {% load staticfiles %}
     <link rel="stylesheet" type="text/css" href="{% static 'mess/css/style.css' %}"> 
     <link rel="stylesheet" type="text/css" href="{% static 'mess/css/bootstrap.min.css' %}">
 </head>
 <body>
     <div class="container">
         <div id="left-content" class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
         {% load staticfiles %}
         <center><img src="{% static 'mess/img/burger.jpg' %}" alt="Please Login here"></center>
         </div>
         <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
             <form action="" method="post">{% csrf_token %}
                 {{ form}}
                 <input  type="submit" value="Submit" />
             </form>
         </div>
     </div>
 </body>
`

It would be a great help if you could resolve me out of this issue. PS: I m a beginner in Django. Django version: 1.8 Please tell me if u need more info. Thanks in advance.


Solution

  • It was because the folder didn't have necessary permissions and Django was unable to access it.