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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:09:36+00:00 2026-05-27T21:09:36+00:00

While developing widgets (objects, which – rendered – use some custom javascript files), I

  • 0

While developing “widgets” (objects, which – rendered – use some custom javascript files), I faced the need of creating kind of “included-scripts-manager” (to avoid double inclusion of same JS file when more than one widget is rendered for the view).

My first idea was to write custom template rendering Context which would provide EXTRA_SCRIPTS variable in the template. However I have no idea where should I collect the list of scripts during request processing? I think that’s where I’d need singleton object.

Any suggestions?

  • 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-27T21:09:37+00:00Added an answer on May 27, 2026 at 9:09 pm

    If you use singleton you will run into thread-safety issue. E.g. your application run in several threads, one thread process single request, so you global object should be per thread, but singleton is unique per process.
    You can use threading.local technique like described in this question. It will provide you object that is unique per thread and so per request.

    However it’s not recommended, so don’t use global variables

    For your situation with widgets there are Media settings in widgets and forms in Django. https://docs.djangoproject.com/en/1.3/topics/forms/media/

    Media objects can also be added together. When two media objects are added, the resulting Media object contains the union of the media from both files.

    So you can fight duplicates with media.
    Also you can combine media right into the template

    {{ form.media|add:info_form.media|add:discount_form.media }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While developing a C++ application, I had to use a third-party library which produced
While developing products, we often need to create proprietary tools to test some of
Many times, while developing Wordpress plug-ins, themes or widgets, we use unnecessary lines of
While developing a Java project, I place all of my jar files in a
While developing my ASP.NET MVC, I have started to see the need for a
I'm developing a web UI using GWT. While working only with the widgets I
While developing a largeish project (split in several files and folders) in Python with
While developing my application i came across some comparison stuff here was it: string
While developing a web application in JSF, I came across an expression which was
While developing for multiple sets of browsers, what issues have you faced while development

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.