RequestContext instance passed to simpletag ?

14 views
Skip to first unread message

Murat Sert

unread,
Jan 18, 2018, 7:57:05 AM1/18/18
to Django users
Hey,

I'm working on upgrading to Django 1.11 and have encountered an issue with simple_tags making use of context. I need to access the context within the tag so declare the decorator as follows.

@register.simple_tag(takes_context=True)

However when I print the type of context at this stage it is an instance of RequestContext. Is this expected behaviour? Because if you wanted todo a render_to_string at the end of the template tag, it'll throw an "unexpected type" error as context as required as a dict but not an instance of RequestContext

my return statement

renderedMessage = render_to_string(template, context)
return mark_safe(renderedMessage)

Regards

Murat
Reply all
Reply to author
Forward
0 new messages