#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 , 8 years ago
Summary: | self.request in views may not be documented yet → Document request/args/kwargs attributes of class-based views |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
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
andself.kwargs
) could be mentioned elsewhere -- perhaps in View.as_view() as that's where the assignment happens.