title: Images not showing up in Django template when using Windows
body: <p>I am learning Django by developing a blog. My code was working in both Linux and Windows. Recently, I started added images to my models with ImageField and it works in Linux but I can't get it to work in Windows. I am using a standalone server.
  Here is my settings.py file:</p>
  
  <pre><code>    MEDIA_ROOT = 'C:/django/third_blog/zblog/media_files/'
      MEDIA_URL = 'C:/django/third_blog/zblog/media_files/'
      STATIC_ROOT = 'C:/django/third_blog/zblog/static'
      STATIC_URL = '/static/'
      STATICFILES_DIRS = (
          'C:/django/third_blog/zblog/media_files/',
      )
      TEMPLATE_DIRS = (
          'C:/django/third_blog/zblog/templates',
      )
      INSTALLED_APPS = (
          'django.contrib.auth',
          'django.contrib.contenttypes',
          'django.contrib.sessions',
          'django.contrib.sites',
          'django.contrib.messages',
          'django.contrib.staticfiles',
          # Uncomment the next line to enable the admin:
           'django.contrib.admin',
          'blog', 
      )
  </code></pre>
  
  <p>I fiddled around with the MEDIA_ROOT, MEDIA_URL, STATIC_ROOT, and STATIC URL to get the code working in Linux. I installed pillow-2.8.1 in windows using pip.</p>
  
  <p>This is my html file in template directory:</p>
  
  <pre><code>    {% load staticfiles %}
      &lt;a href = "/"&gt;Back to homepage &lt;/a&gt;
      {% if list_of_blog_entries %}
          &lt;ol&gt;
          {% for blog_entry in list_of_blog_entries %}
             &lt;li&gt; {% for blog_item in blog_entry %}
                  {% if blog_item.image %}
                      &lt;img src = "{{ blog.item.url }}" height=100&gt; &lt;/br&gt;
                  {% endif %}
              {% endfor %} &lt;/li&gt; &lt;/br&gt; &lt;/br&gt;
          {% endfor %}
          &lt;/ol&gt;
  
      {% else %}
          &lt;p&gt; Blog is empty &lt;/p&gt;
      {% endif %}
  </code></pre>
  
  <p>This is my views.py file:</p>
  
  <pre><code>    # other imports
      import zblog.settings as settings_file
      #from PIL import *
      import PIL
      def list_posts(request):
          """
          Lists the posts with their contents on a single page.
          """
  
              ###
  
              # I stands for image or photo.
              if post_item == "I":
                  items_in_post.append(post.postimage_set.get(image_id=post_item_id))
                  try_image=post.postimage_set.get(image_id=post_item_id)
                  print try_image.image.url
                  print settings_file.MEDIA_ROOT+try_image.image.url
                  print try_image.image
                  print
                  print
                  image_counter += 1
  
  
              list_of_blog_entries.append(items_in_post)
  
          return render_to_response("blog/list_posts.html",  \
                                    {'list_of_blog_entries' : list_of_blog_entries, \
                                     'image_root':settings_file.MEDIA_URL})
  </code></pre>
  
  <p>I have a lot of other code that I have not posted. I have forms for uploading an image. The image is successfully uploaded and is found in the subdirectory media_file/blog. When I try to list the image with , it shows a broken link to the image. So I printed out the url with "print try_image.image.url" in views.py to find that the url is with respect to the home directory "blog/IMG.jpg". So I added the MEDIA_ROOT and find that I now get the complete directory path "C:/django/third_blog/zblog/media_files/blog/IMG.jpg".</p>
  
  <p>I passed the variable MEDIA_ROOT to the template and changed the template to</p>
  
  <pre><code>    &lt;img src = "{{ image_root }}{{ blog.item.url }}"&gt;
  </code></pre>
  
  <p>Now I get a blank space where the image should have been. Spent the past hour googling and found the links I first used to get it going in Linux. Is there anything specific to Windows? I am using Django 1.7 with Python 2.7.3.</p>
  
  <p>Thanks in advance.</p>
  
  <p>*************EDIT*********
  My directory structure is:</p>
  
  <pre><code>    C:
          django
              thrid_blog
                  zblog
                      blog
                      media_files
                      static
                      zblog
                      manage.py
  </code></pre>
  
  <p>My settings.py file in the last zblog directory. So, I put:</p>
  
  <pre><code>    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
  </code></pre>
  
  <p>in my manage.py file and in my settings.py file, I put</p>
  
  <pre><code>    import sys
      sys.path.append("c:\django\third_blog\zblog")
      from manage import BASE_DIR
  </code></pre>
  
  <p>to get BASE_DIR pointing to the home directory of the project which contains the directories blog, media_files, static, zblog. But it still doesn't work.</p>
  
  <p>Also, even when I hardcode the image into the HTML:</p>
  
  <pre><code>    &lt;img src = "C:\django\third_blog\zblog\media_files\blog\IMG_20141125_104718.jpg" height=100&gt; &lt;/br&gt;
  </code></pre>
  
  <p>It still doesn't show the image. It gives me a blank space.</p>