render() in django.shortcuts calls render_to_string method of loader module, which calls render method of Template class by creating a Template object. Till now, context is a dictionary. Inside render method in Template class,
context.render_context.push_state(self):
How does this works? Because render_context is an attribute of Context class which gets assigned a RenderContext object. So, how context being not an instance of Context class can access its attribute?
context is being setup when calling Template render
method
context = make_context(
context, request, autoescape=self.backend.engine.autoescape
)