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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:34:53+00:00 2026-05-18T06:34:53+00:00

I have a template tag that includes a template: def WidgeLoaderNode(IncludeNode): def __init__(tpl, scopes=None):

  • 0

I have a template tag that includes a template:

def WidgeLoaderNode(IncludeNode):
    def __init__(tpl, scopes=None):
        self.scopes = scopes
                    self.tpl = tpl
        super(WidgeLoaderNode, self).__init__('""')

    def render(self, context):
                    self.template_name = self.tpl.resolve(context)
        scopes = self.scopes.resolve(context) if options else DEFAULT_SCOPES
        context.push()
        context['form'] = ScopeForm(scopes)
        fragment = super(WidgeLoaderNode, self).render(context)
        context.pop()
        return fragment

@register.tag
def widget_form(parser, token):
    bits = token.split_contents()
            tpl = parser.compile_filter(bits[1])
    scopes = parser.compile_filter(bits[2]) if len(bits) > 2 else None
    return WidgeLoaderNode(tpl, scopes)

The template has to be specified from the template. In those templates, I need to include a couple of tag libraries:

{% load widgets_tags helpers %}

. Is it possible to reduce boilerplate template code in them by loading those libraries from my node code?

  • 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-18T06:34:53+00:00Added an answer on May 18, 2026 at 6:34 am

    Maybe you could use something like this: http://djangosnippets.org/snippets/342/ – i.e. django.template.add_to_builtins

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

Sidebar

Related Questions

As I have understood the match atribute of a template tag, it defines what
I want to refresh a div tag in Django that contains temperature data. The
Any ideas regarding why the WPF XAML code I have is not working. I'm
Not sure how to word the question concisely :). I have say 20 Posts
I have a form, and for layout (and future use), i would like to
I'm new in Django and Python and I'm stuck! It's complicated to explain but
Normally someone would just go and grab Boost's Function Output Iterator but I'm not
I am working on a simplistic website using PHP, a language I haven't touched
I've modified James' flattening iterator to act as a bidirectional iterator if possible, but
My site is quite visual and I would like to make use of users

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.