title: cant make connections betwen uploaded image and template django
body: <p>I'm trying to upload a picture for my post model by admin panel but I can't display it in my template, please help
  this is my post model
  and I get this error please help me
  ValueError at /
  The 'Img' attribute has no file associated with it.</p>
  <pre><code>class Post(models.Model):
      author = models.ForeignKey('auth.User', on_delete=models.CASCADE ,null=True)
      title = models.CharField(max_length=200,default='a')
      text = models.TextField(default='a')
      Img = models.ImageField(upload_to='images/',null =True)
  </code></pre>
  <p>and  for urls.py i used this code:</p>
  <pre><code>if settings.DEBUG: # new
      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  <p>and views.py:</p>
  <pre><code>def post_list(request):
      posts= Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
      return render(request, 'post/index.html', {'posts': posts})
  </code></pre>
  <p>and finally my index.html template:</p>
  <pre><code>{% for post in posts %}
  
                      &lt;div class=&quot;blog-post-thumb &quot;&gt;
                          &lt;div class=&quot;blog-post-image &quot;&gt;
                              &lt;a href=&quot;single-post.html &quot;&gt;
  
  
                                  &lt;img src=&quot;{{post.Img.url}}&quot; class=&quot;img-responsive &quot; alt=&quot;Blog Image &quot;&gt;
                              &lt;/a&gt;
                          &lt;/div&gt;
                          &lt;div class=&quot;blog-post-title &quot;&gt;
                              &lt;h3&gt;&lt;a href=&quot;single-post.html &quot;&gt;{{ post.title }}&lt;/a&gt;&lt;/h3&gt;
                          &lt;/div&gt;
                          &lt;div class=&quot;blog-post-format &quot;&gt;
                              &lt;span&gt;&lt;a href=&quot;# &quot;&gt;&lt;img src=&quot;images/author-image1.jpg &quot; class=&quot;img-responsive img-circle &quot;&gt;A&lt;/a&gt;&lt;/span&gt;
                              &lt;span&gt;&lt;i class=&quot;fa fa-date &quot;&gt;&lt;/i&gt; published: {{ post.published_date }}&lt;/span&gt;
                              &lt;span&gt;&lt;a href=&quot;# &quot;&gt;&lt;i class=&quot;fa fa-comment-o &quot;&gt;&lt;/i&gt;  Comments&lt;/a&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class=&quot;blog-post-des &quot;&gt;
                              &lt;p&gt;{{ post.text|linebreaksbr }}&lt;/p&gt;
                              &lt;a href=&quot;single-post.html &quot; class=&quot;btn btn-default &quot;&gt;Continue Reading&lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  {% endfor %}
  </code></pre>