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 5999871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:36:47+00:00 2026-05-23T00:36:47+00:00

I am using imagefield to render images. These are the urls; (r’^site_media/(?P<path>.*)$’, ‘django.views.static.serve’, {‘document_root’:

  • 0

I am using imagefield to render images. These are the urls;

    (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': site_media}),
    (r'^$', 'webapp.blog.views.index'),
    url(
        r'^blog/view/(?P<slug>[^\.]+).html', 
        'webapp.blog.views.view_post', 
        name='view_blog_post'),

These are the views:

def index(request):
    return render_to_response('index.html', {
        'categories': Category.objects.all(),
        'posts': Blog.objects.all()[:5]
    })

def view_post(request, slug):   
    return render_to_response('view_post.html', {
        'post': get_object_or_404(Blog, slug=slug),
    })

If I call a image object in the index page with {{ posts.photos.url }} it properly maps to http://127.0.0.1/site_media/images/image.jpg. But if I call the image object on view_post template it gets mapped to http://127.0.0.1/blog/view/site_media/images/image.jpg. How can I make view_post function map image urls to the proper http://127.0.0.1/site_media/images/image.jpg url.

  • 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-05-23T00:36:48+00:00Added an answer on May 23, 2026 at 12:36 am

    This is not a function of your urlconf, but how you are displaying the images in your template. You are probably doing something like this:

    <img src="site_media/images/image.jpg">
    

    when you should be doing

    <img src="/site_media/images/image.jpg">
    

    … note the initial slash. Alternatively, if you’re using STATIC_URL or MEDIA_URL, make sure they’re defined with the initial slash in your settings.py.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Django to create a stock photo site, I have an ImageField in
I'm using jquery form plugin http://jquery.malsup.com/form/#getting-started to upload images to django server side. There
I'm using django-storages with amazon S3, and uploading image files with: models.ImageField(upload_to=img=%Y-%m-%d, max_length=256, blank=True,
I'm going to edit an ImageField using jquery ajax,after searching I found out I
I have a model: class Foo(models.Model): poster = models.ImageField(uPoster, upload_to='img') I'm using the admin
This is killing me! I'm using django-filebrowser, and I want to create a gallery
I'm using jquery form plugin http://jquery.malsup.com/form/#getting-started to upload images through ajax. When I try
I'm using Django and Tastypie to create a RESTful web app. I have a
I'm using django and jquery for image uploading. First we upload an image using
I am working on a cookbook website using django and have run into a

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.