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)
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.
Renders:
I would recommend reducing the method signature on that template tag and just pass in objects where you’re passing in multiple object properties.