Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28294 closed Cleanup/optimization (fixed)

Document request/args/kwargs attributes of class-based views

Reported by: Tony Narlock Owned by: Michael Vasiliou
Component: Documentation Version: 1.11
Severity: Normal Keywords: documentation views
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the community, there is a convention of pulling HttpRequest from self.request. Especially due to the prominence of .as_view as a pattern to invoke views.

This binding occurs in .as_view(): https://github.com/django/django/blob/711123e/django/views/generic/base.py#L63

CBV documentation doesn't mention it: https://docs.djangoproject.com/en/1.11/topics/class-based-views/intro/

If a user is using .as_view() in a high level view, they won't see HttpRequest being passed in as a method argument unless they're using something like .get() or .post()

Documentation should be clarify where and how self.request in views comes into the life cycle of a view.

Change History (5)

comment:1 by Tim Graham, 7 years ago

Summary: self.request in views may not be documented yetDocument request/args/kwargs attributes of class-based views
Triage Stage: UnreviewedAccepted

Using the documentation search for "self.request" I found a mention in the Dynamic filtering section, but I agree that it (and other attributes like self.args and self.kwargs) could be mentioned elsewhere -- perhaps in View.as_view() as that's where the assignment happens.

comment:2 by Michael Vasiliou, 7 years ago

Owner: changed from nobody to Michael Vasiliou
Status: newassigned

comment:3 by Tim Graham, 7 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 63e9a71:

Fixed #28294 -- Doc'd request/args/kwargs attributes of class-based views.

comment:5 by Tim Graham <timograham@…>, 7 years ago

In a6756195:

[1.11.x] Fixed #28294 -- Doc'd request/args/kwargs attributes of class-based views.

Backport of 63e9a71ec4917ddf7f4acbf69a7ccdafb76fb2ee from master

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