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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:29:33+00:00 2026-06-14T11:29:33+00:00

My web page makes an AJAX call to the server to dynamically select an

  • 0

My web page makes an AJAX call to the server to dynamically select an image for display. The problem I’ve run into is that the STATIC_URL variable evaluates to an empty string, and so the image fails to load.

This is the code I’m using the render the path to the image.

text = "<img src=\"{{ STATIC_URL }}/images/%s\"> %s" % (ball_file, val)
t = Template(text)
tt = t.render(Context())

Any help would be much appreciated.

  • 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-14T11:29:35+00:00Added an answer on June 14, 2026 at 11:29 am

    Why even use Template ? Wouldn’t this work ?

    from django.conf import settings
    
    text = u'<img src="%simages/%s"> %s' % (settings.STATIC_URL, ball_file, val)
    

    Note that STATIC_URL should contain the trailing slash, hence %simages in this example instead of %s/images.

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

Sidebar

Related Questions

I have a main web page (Base Page) that makes an ajax call (using
My web page makes AJAX calls to a server and displays the result in
I'm trying to debug a web page that makes heavy use of events, and
I need to design a page for a web application that makes sense for
I have a webpage that makes an ajax call to get some data. That
In summary : I have an ASP.NET web page that causes an AJAX postback
After an Ajax call I reload a web page. I have two options.. I
I am trying to make web page which would display two other webpages side
I'm trying to make a web scraper that will parse a web-page of publications
When using Visual Studio's built in web server, every time I make a page

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.