Django Thread-Safety for templatetags
I am coming here, because 开发者_C百科I have a question about Django and Thread. I read the documentation http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#template-tag-thread-safety and I would like to now if the next code could be impacted also, at the rendering context.
class ChatterCountNode(NodeBase):
def __init__(self, channelname, varname):
self.channelname = channelname
self.varname = varname
def render(self, context):
channelname = self.getvalue(context, self.channelname)
varname = self.getvalue(context, self.varname)
count = get_channel_count(channelname)
context[varname] = count
return ''
No, your code is thread safe. See the example they have in the docs with the cycle tag.
精彩评论