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

  • Home
  • SEARCH
  • 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 7580783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:00:12+00:00 2026-05-30T18:00:12+00:00

I’m trying to setup my static file in development. I have an image located

  • 0

I’m trying to setup my static file in development. I have an image located in polls/static/images/banner.jpg. When I navigate to 127.0.0.1:8000/ the banner shows up, but when I go to something like 127.0.0.1:8000/2ndpage the banner breaks.

my index (URL: 127.0.0.1:8000/) template contains:

{% include 'polls/header.html' %}

The URL for the banner http://127.0.0.1:8000/static/images/banner.jpg

my 2ndpage template also contains:

{% include 'polls/header.html' %}

But the URL for the banner changes to http://127.0.0.1:8000/2ndpage/images/banner.jpg

my polls/header.html template:

<img src="{{ STATIC_URL }}images/gcs_banner.jpg" />

urls.py

from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('polls.views',
    url(r'^$', 'index'),
    url(r'^2ndpage/$', '2ndindex'))

views.py

def index(request):
    ...
    return render_to_response('polls/index.html', {'latest_people_list':     latest_people_list,}, context_instance = RequestContext(request))

def 2ndpage(request, people_id):
    ...
    return render_to_response('index/detail.html', {'people': p}, context_instance = RequestContext(request))

Why does the URL change from ../static/.. to ../2ndpage/..? How do I fix this so that when I use {% include ‘polls/header.html’ %} the banner always shows up?

  • 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-30T18:00:14+00:00Added an answer on May 30, 2026 at 6:00 pm

    I think that in the second page, {{ STATIC_URL }} is not defined. Thus, src ends up with images/gcs_banner.jpg. Which is a relative url because it’s not prefixed with a slash. It is then converted to a absolute path using the current absolute url: /2ndpage/images/gcs_banner.jpg.

    {{ STATIC_URL }} is probably set by a context processor – at least that how it works in my projects. Context processors are actually a feature from RequestContext. When a view returns response without RequestContext then the context processors are not run, e.g.:

    from django import shortcuts 
    # ....
        return shortcuts.render_to_response(template_name, context)
    

    This is an example of explicit usage of RequestContext with render_to_response():

    from django import shortcuts 
    from django import template
    # ....
        return shortcuts.render_to_response(template_name, context, 
            context_instance=template.RequestContext(request))
    

    That said, Django 1.3 provides a better shortcut with implicit usage of RequestContext, render():

    from django import shortcuts 
    # ....
        return shortcuts.render(request, template_name, context)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
I am trying to render a haml file in a javascript response like so:
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.