Re: Request object problem
ya correct, now i got complete picture of client.get() and RequestFactory, On Wed, Sep 22, 2010 at 5:28 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > On 22 sep, 13:17, girish shabadimathwrote: > > Thanks for the reply, actually the response object got using > RequestFactory > > is different from the one returned by client.get() function,, > > The reponse object you get using RequestFactory is the one returned by > your view. > > > i think response object returned by client.get() supports > response.template > > and response.context['data'],,, > > The test.Client uses quite a few Django hooks (middlewares, signals > etc) to takes care of all this: > > http://code.djangoproject.com/browser/django/trunk/django/test/client.py > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Girish M S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Request object problem
On 22 sep, 13:17, girish shabadimathwrote: > Thanks for the reply, actually the response object got using RequestFactory > is different from the one returned by client.get() function,, The reponse object you get using RequestFactory is the one returned by your view. > i think response object returned by client.get() supports response.template > and response.context['data'],,, The test.Client uses quite a few Django hooks (middlewares, signals etc) to takes care of all this: http://code.djangoproject.com/browser/django/trunk/django/test/client.py -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Request object problem
Thanks for the reply, actually the response object got using RequestFactory is different from the one returned by client.get() function,, i think response object returned by client.get() supports response.template and response.context['data'],,, ref:( http://djangosnippets.org/snippets/963/ ) On Wed, Sep 22, 2010 at 4:24 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > On 22 sep, 11:31, girish shabadimathwrote: > > hi all, > > > > i used django snippethttp://djangosnippets.org/snippets/963/ > > > > and successfully created request object > > > > i checked the response.status_code its giving 200 > > > > i checked response.content it matches with the browser source code > > > > when i issue *response.template* it gives error > > and* response.context* also not giving output,, > > > > i used template and context data in view function,, > > > > why its showing nothing..? > > because, while the template and context are used to build the response > object, they are not part of it. render_to_response(templatename, > context, ...) is just a convenient shortcut that loads the template, > render it with the context, and build an HttpResponse using the > generated content. > > FWIW, Django is not only mostly well documented but also OSS, so you > can read the code to see what's going on: > > > http://code.djangoproject.com/browser/django/trunk/django/shortcuts/__init__.py > > http://code.djangoproject.com/browser/django/trunk/django/http/__init__.py#L302 > > As you can see, the HttpResponse object is built from some content - > how this content is generated is totally orthogonal. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Girish M S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Request object problem
On 22 sep, 11:31, girish shabadimathwrote: > hi all, > > i used django snippethttp://djangosnippets.org/snippets/963/ > > and successfully created request object > > i checked the response.status_code its giving 200 > > i checked response.content it matches with the browser source code > > when i issue *response.template* it gives error > and* response.context* also not giving output,, > > i used template and context data in view function,, > > why its showing nothing..? because, while the template and context are used to build the response object, they are not part of it. render_to_response(templatename, context, ...) is just a convenient shortcut that loads the template, render it with the context, and build an HttpResponse using the generated content. FWIW, Django is not only mostly well documented but also OSS, so you can read the code to see what's going on: http://code.djangoproject.com/browser/django/trunk/django/shortcuts/__init__.py http://code.djangoproject.com/browser/django/trunk/django/http/__init__.py#L302 As you can see, the HttpResponse object is built from some content - how this content is generated is totally orthogonal. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Request object problem
hi all, i used django snippet http://djangosnippets.org/snippets/963/ and successfully created request object i checked the response.status_code its giving 200 i checked response.content it matches with the browser source code when i issue *response.template* it gives error and* response.context* also not giving output,, i used template and context data in view function,, why its showing nothing..? shell cmds: >>>rf = RequestFactory() >>>get_req = rf.request('/details') >>> response = detail(get_req, 27000) >>> response.status_code 200 >>> response.content '\n\ndetails\n .\n\n\n' >>> response.template Traceback (most recent call last): File "", line 1, in AttributeError: 'HttpResponse' object has no attribute 'template' >>> response.context['data'] Traceback (most recent call last): File "", line 1, in AttributeError: 'HttpResponse' object has no attribute 'context' -- Girish M S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.