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

  • Home
  • SEARCH
  • 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 6196597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:40:20+00:00 2026-05-24T03:40:20+00:00

Template code: {% extends ‘some.html’ %} {% load tag %} {% get_rate land contDetails.postcode

  • 0

Template code:

{% extends 'some.html' %}
{% load tag %}
{% get_rate land contDetails.postcode contDetails.county title uid LsAff.aff_id LsAff.group_id %}

custom template tag:

 from django import template
 from process.utils.error_handler import  debug_logger
 from django.template import Library, Node, TemplateSyntaxError
 class land(template.Node):
   def __init__(self, var):
      self.varname = template.Variable(var)
      debug_logger().info(self.varname)

   def render(self, context):
     debug_logger().info("hello")
     user = self.varname.resolve(context)
     debug_logger().info("hello")
     debug_logger().info(user)
     return "somestring"

def get_rate(parser, token):
   debug_logger().info("hell")
   bits=token.split_contents()
   var=bits[2]
   debug_logger().info(var)
   return land(var)
register = template.Library()
register.tag('get_rate', get_rate)

In the above code def render(self, context): function is not calling.
Till debug_logger().info(self.varname) statement the code works properly.

Am i missing anything?
please help to find the solution to call render(self, context)

  • 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-24T03:40:21+00:00Added an answer on May 24, 2026 at 3:40 am

    I set up a quick view function and replicated your tag. I reduced the number of arguments to two for brevity. Everything is working ok for me.

    #views.py
    from django.shortcuts import render
    
    def test_view(request):
        return render(request, 'test.html', {'var' : True})
    
    #tag.py
    from django import template
    
    register = template.Library()
    
    @register.tag('get_rate')
    def get_rate(parser, token):
        bits = token.contents.split()
        var = bits[2]
        return LandNode(var)
    
    class LandNode(template.Node):
        def __init__(self, var):
            self.varname = template.Variable(var)
    
        def render(self, context):
            varname = self.varname.resolve(context)
            return 'some string'
    
    #test.html
    {% load tag %}
    {% get_rate 'foo' var %}
    

    Renders:

    some string
    

    I would recommend reducing the method signature on that template tag and just pass in objects where you’re passing in multiple object properties.

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

Sidebar

Related Questions

I have some template code that I would prefer to have stored in a
I want to provide some template for a code generator I am developing. A
I wrote a template class which extends STL list for some use. I declare
Template code is not compiled until the template function is used. But where does
Are there any issues which might make MS's T4 Template code-generation system unsuitable for
This is using the web app framework, not Django. The following template code is
In code: template<class T,int row, int col> void invert(T (&a)[row][col]) { T* columns =
The following code: template <typename S, typename T> struct foo { void bar(); };
Consider the following code: template <int dim> struct vec { vec normalize(); }; template
Please consider this code: template<typename T> char (&f(T[1]))[1]; template<typename T> char (&f(...))[2]; int main()

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.