Variable of context processors does not work with render_to_string

0

In some places on my system, I render a page with render_to_string , because I want to render only a small content. In these cases I do not get my variables that I created in context_processors . Does anyone have a solution other than manually passing the variable in the render_to_string dictionary? Thank you.

update

After a good researched I discovered that in previous versions of Django (I found in version 1.9 ) there was a parameter in the render_to_string called context_instance, where I passed the RequestContext and it already loaded the dictionary with context_processors variables. But for some reason it was removed from the new versions. I still do not have a solution to load context_processors into render_to_string . I really need the String containing the HTML loaded with my conditions that I use for some variables of context_processors . So still my problem persists.

    
asked by anonymous 05.07.2018 / 01:00

1 answer

0

I think you should do just that:

html_body = render_to_string(template_name, context, request=request)
    
15.07.2018 / 20:47