To create our own custom template tags we have to define a Node subclass 
which implements a render method.

Example from 
https://docs.djangoproject.com/en/2.2/howto/custom-template-tags/#auto-escaping-considerations

import datetimefrom django import template
class CurrentTimeNode(template.Node):
    def __init__(self, format_string):
        self.format_string = format_string

    def render(self, context):
        return datetime.datetime.now().strftime(self.format_string)




It seems the context parameter for the render function is a 'context object' 
and not a 'request context object'.  Indeed this section of the same article 
seems to support this - To create our own custom template tags we have to 
define a Node subclass which implements a render method.


Anyway when I followed the example and printed the context object it looks to 
be a request object.  Is this a bug?  I'm using the latest django.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0da9dab2-6c42-4e2f-ac30-f42818e5b35c%40googlegroups.com.

Reply via email to