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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:56:52+00:00 2026-06-11T21:56:52+00:00

newb to pyramid and python. I’ve been able to link to my static files

  • 0

newb to pyramid and python. I’ve been able to link to my static files successfully in any of my jinja2 templates, ie:

<link rel="stylesheet" type="text/css" href="{{'myproject:static/mycss.css'|static_url}}"></link>

The .css file loads fine and I can link to any images that are inside my static folder as long as I do it within the jinja template.

I’d like to use an image as a background but am having trouble linking to the image in my css file:

#mydiv{
background-image:url("{{'myproject:static/myimage.gif'|static_url}}");
}

This link shows up in mycss.css as

"{{'myproject:static/myimage.gif'|static_url}}"

and doesn’t show up as a link. (if I load an externally hosted image as my background-image it works)

thx!

  • 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-11T21:56:53+00:00Added an answer on June 11, 2026 at 9:56 pm

    Your CSS file is a static file, and thus is not treated as a template. All static resources are served as-is, without any processing.

    All non-absolute URLs in a CSS file are relative to the location from where the CSS file has been loaded; if you use background-image:url("myimage.gif"), the browser loads the image relative to your CSS file location. Since the CSS was loaded from http://yoursite/static/mycss.css, the image will be loaded from http://yoursite/static/myimage.gif.

    Alternatively, if you referencing files from unusual locations (for example, images auto-generated by one of your views), you’ll have to add your CSS file as a view instead, and render it with a (text) template.

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

Sidebar

Related Questions

Python newb...beware! I am trying to recursively ftp some files. In the script below,
A newb question and one I haven't been able to see much advice on,
Python newb here. I m trying to count the number of letter as in
Newb programmer here, I'm most familiar with Python but also learning C and Java,
Total newb to .NET programming (and AJAX) but I've been working on this program
I'm a newb here, and it may be because I've been up since yesterday
Python newb and first-time poster... I'm building a mass disk copying program and have
Maven newb here.. Is there any way to open a console in eclipse and
I'm a database newb, so please forgive me if this has been covered a
Python newb here looking for some assistance... For a variable number of dicts in

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.