A context contains the variables that you want your template to be able to
access.  It is common to want to access stuff from the request.  You could
copy those things that you need into the dict that you pass to the Context
constructor or define an element of the dict to hold the Request object and
let the template dig that stuff out..  RequestContext initializes the
Context according to the dictionary you pass, but also runs you configured
set of context processors, which can paw through the Request object and add
values to your Context's dictionary(s).  See:
https://docs.djangoproject.com/en/2.1/ref/templates/api/

render() turns your template (and context) into a string representing the
body of the response.  render_to_response() does that and uses it to
initialize an HttpResponse object that contains that, plus all suitable
response headers, some defaulted, like content type and content length,
override-able by you, and any additional headers you choose to add, and
also the response status, 200 by default, and corresponding status string,
which you can override if needed.  You need an HttpResponse object to
return from a view so that Django can build the whole response.

Of course, all this is in the documentation.

On Fri, Aug 10, 2018 at 5:37 PM shivam sharma <
talk2shivamsharma19...@gmail.com> wrote:

> Can someone explain me difference between Context object and
> RequestContext obj.
> And also difference between
> render_to_response() and render()
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKd5AUUPToxjMeg%2B47ENB3T5KQ%2BXyRVb%2BNKnGLKsGz10OyRFPg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKd5AUUPToxjMeg%2B47ENB3T5KQ%2BXyRVb%2BNKnGLKsGz10OyRFPg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0vxXEOg%3DY7Y-9GCBcVbwfaU9eHdG%3D91emsRi0JWUUqcXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to