Opened 3 years ago

Closed 3 years ago

#33542 closed Bug (invalid)

TemplateResponse example missing definition of request

Reported by: phisp Owned by: nobody
Component: Documentation Version: 4.0
Severity: Normal Keywords: TemplateResponse request
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In https://docs.djangoproject.com/en/4.0/ref/template-response/

>>> t = TemplateResponse(request, 'original.html', {})

"NameError: name 'request' is not defined"

How can I define request by the shell? HttpRequest?

A link how to define the request in the shell would be appreciated. I know Documentation isn't a tutorial, annoying is this happens very often and a deeper understanding with the shell would be helpful.

Thanks for your work

Change History (3)

comment:1 by Tim Graham, 3 years ago

Summary: executing the shell commands promts an errorTemplateResponse example missing definition of request

If you look at the documentation of the TemplateResponse arguments a little earlier, it says: request - An HttpRequest instance.

I'm doubtful that further clarification would be helpful, especially because an original.html template isn't likely to be present.

in reply to:  description comment:2 by Samuel Hartmann, 3 years ago

Based on Advice for new contributors, I've been able to reproduce the bug.

But as phisp says:

Documentation isn't a tutorial

And I agree with Tim Graham:

TemplateResponse [...] it says: request - An HttpRequest instance.

I'm doubtful that further clarification would be helpful, especially because an original.html template isn't likely to be present.

Further explanation would only make sense within a tutorial, describing the project setup (including original.html for example).

I am a Django beginner, with some basic experience in web scraping and no professional background in computer science.
But I think I would be able to create an HttpRequest object, using the source mentioned by Tim.

Therefore regard this ticket as invalid and would close it in this sense.

comment:3 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

Agreed.

Note: See TracTickets for help on using tickets.
Back to Top