Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:20:25+00:00 2026-06-05T07:20:25+00:00

The image can upload to the file upload which located in mysite file, here

  • 0

The image can upload to the file “upload” which located in mysite file, here is my code
setting.py

MEDIA_ROOT = 'C:/Python26/mysite/upload/media/'
MEDIA_URL = '/media/'

In the url.py

urlpatterns = patterns('',

   url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT,}),
)

In the template

 <img src="{{MEDIA_URL}}/{{pic}}" alt="Profile Picture" width="200"/>

However, the image still does not show in the website, but it indeed stored in the upload file. Someone could help me with that? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:20:27+00:00Added an answer on June 5, 2026 at 7:20 am

    Given:

    MEDIA_URL = '/media/'
    

    And the following template code:

    <img src="{{MEDIA_URL}}/{{pic}}" alt="Profile Picture" width="200"/>
    

    The image src couldn’t possibly be /upload/Desert.jpg. The path should be starting with /media/. More likely than not MEDIA_URL is undefined and the value of pic is upload/Desert.jpg. If that’s the case, then you’re probably missing the media template context processor. Change TEMPLATE_CONTEXT_PROCESSORS to:

    TEMPLATE_CONTEXT_PROCESSORS = (
        ...
        'django.core.context_processors.media',
    )
    

    That will make MEDIA_URL available in your template context. Then, you’ll also need to remove the slash after it, or you’ll end up with two (MEDIA_URL ends with a slash), i.e.:

    Instead of:

    {{ MEDIA_URL }}/{{ pic }}
    

    Use:

    {{ MEDIA_URL }}{{ pic }}
    

    UPDATE

    If you’re still not getting a value for MEDIA_URL, then you’re probably not using RequestContext. You have to wrap your view’s context in RequestContext in order for the template context processors to do their thing.

    If you’re using render_to_response, then:

    return render_to_response('template.html', { ... context here ... }, context_instance=RequestContext(request))
    

    If you’re using Django 1.3+, you can just use the render method, which will do this for you automatically:

    return render('template.html', { ... context here ... })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been doing research on image file upload security for a while but can't
i have a form in which user can upload 100 mb file which results
I use this code to upload image files in xammp server: <?php if ((($_FILES[file][type]
I want to create a mountable image with the newfs file system which can
I have a file upload class which returns an image resize object if the
i'm trying to create form which with which i can upload text and image
In a rather simple ASP.NET application where the user can upload a image, mostly
In my website, the user can upload a profile image. The website structure is
I can't seem to upload an image using Zend_Service_Nirvanix. Is it even possible? I
I have an image file which is stored onto database as a blob (shown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.