0

When following code is invoked:

@register.inclusion_tag('template.html', takes_context=True)
def method(context, content_template):
    contents = template.loader.get_template(content_template)
    context['content'] = contents.render(context)
    return context

I get warning:

RemovedInDjango110Warning: render() must be called with a dict, not a RequestContext.

Warning disappers when second line of method is refactored to:

context['content'] = contents.render(context.flatten())

But I guess it is a walkaround, not a properly solution of this problem.

  • 2
    Possible duplicate of [How to fix a Deprecation Warning in Django 1.9](http://stackoverflow.com/questions/35002061/how-to-fix-a-deprecation-warning-in-django-1-9) – Sayse Jul 13 '16 at 07:45
  • Mentioned questions don't ask about this particular issue. Here, Django itself provides a RequestContext, but the way to forward it to another template withotu triggering a warning is not clear. – Adrian17 Jul 13 '16 at 08:01
  • The code itself makes no sense though. An inclusion tag is *already* rendering another template, in this case "template.html". Why would you, as the only code inside that tag, render a *third* template? – Daniel Roseman Jul 13 '16 at 08:04
  • It's not the whole content of the function, but only the relevant part. It does make sense in bigger context. – Krzysztof Gromadzki Jul 13 '16 at 08:08

0 Answers0