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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:06:10+00:00 2026-06-18T05:06:10+00:00

I have redefined this question from the original a bit to make it more

  • 0

I have redefined this question from the original a bit to make it more fundamental to the question at hand. The relevant parts of my filesystem are as follows.

env
    tutorial
        tutorial
            templates
                view.pt
            static
                myjava.js
            views.py
            __init__.py

Right now my view.pt template has

<script type="text/javascript" src="/static/myjava.js"></script>

Then in my __init__.py, I have

config.add_static_view(name='static',path='env/tutorial/tutorial/static')

And finally, the myjava.js file itself is very simple:

document.write("hello from the javascript file")

I am trying to follow this document: http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/assets.html

but right now none of the text is showing up. I feel like the problem lies in the paths i am giving it.

Some ideas I have had: in the config.add_static_view, the name=’static’ is confusing. I want users to be able to visit the url http://www.domain.com/firstpage, where firstpage is the result of a template that uses a javascript file resource (a file in the static folder). I am worried that these static assets are only for urls that start with http://www.domain.com/static/&#8230; Is this a valid concern? How can I tell the config.add_static_view function to serve the static resources for any views rendered from the view.pt template?

Edit: here is what worked:

in the template, use src=”${request.static_url(‘tutorial:static/myjava.js’)}”

then in the init.py use config.add_static_view(name=’static’,path=’tutorial:static/’)

  • 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-18T05:06:11+00:00Added an answer on June 18, 2026 at 5:06 am

    Your javascript link, in the template, should be something like src="${request.static_url('tutorial:static/myjava.js')}"

    This allows your application to be more easily relocated.

    This also uses the appropriate asset specification, using the name of the package,
    “tutorial”, a colon, then a path relative to the location of the “tutorial” package, which in your case the package is at env/tutorial/tutorial.

    Edited: I forgot about the Configurator object.

    Here, you want to use a similar asset specification such as config.add_static_view('static', 'tutorial:static/').

    You can make different static views for different directories as well, like: config.add_static_view('images', 'tutorial:images/')

    When you do things like this, you can move the root of your application to another location, allowing you to have http://mysite.com/stable/ and http://mysite.com/devel/ having accesses to / be rewritten to /stable/.

    The static views can be called from any template with code like ${request.static_url('tutorial:images/icons/favicon.ico')}

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

Sidebar

Related Questions

(This question is more for the people who have access to the book, It's
I have just started using RadControls so this question might be basic for you,
I know I have asked this question in a different manner earlier today but
This is a follow up to my question from yesterday - where a comment
This is a question of converting strings from DB2 to SQL Server. On DB2
I have an XML Template file. This file contains a header and some predefined
UPDATE: Redefined what I am trying to do. I have a model of Contact,
I have a SMTP server that only accepts a predefined From sender. However, I
have written this little class, which generates a UUID every time an object of
Related: Lazy datatypes in Objective C From the related question I was able to

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.