#24126 closed Cleanup/optimization (fixed)
Consider deprecating the current_app argument of auth views
| Reported by: | Aymeric Augustin | Owned by: | lukawoj |
|---|---|---|---|
| Component: | contrib.auth | Version: | dev |
| Severity: | Normal | Keywords: | current_app |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
All views defined in django.contrib.auth.views have the following structure:
def view(request, ..., current_app=None, ...):
...
if current_app is not None:
request.current_app = current_app
return TemplateResponse(request, template_name, context)
As of Django 1.8 current_app is set on the request object. (This is debated but no other concrete proposal has been made at this time.)
For consistency the auth views should require the caller to set it on the request instead of passing it in a separate argument.
That would also avoid the risk of conflicts between a current_app set on the request and another current_app passed in argument. Currently the latter overrides the former.
Change History (8)
comment:1 by , 11 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 11 years ago
| Keywords: | current_app added; multiple-template-engines removed |
|---|
comment:3 by , 10 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 10 years ago
| Has patch: | set |
|---|
Submitted pull request https://github.com/django/django/pull/4813
comment:5 by , 10 years ago
| Needs documentation: | set |
|---|
comment:6 by , 10 years ago
It looks like the use case for adding current_app was for the admin: cc64fb5c4b4315a4ad66e21458e27ece57266847.
If we automatically set the current_app as suggested in #24127, that would allow us to proceed with this deprecation without having to add request.current_app = request.resolver_match.namespace in all the admin callers in contrib/admin/sites.py.
I guess the use case of making it a view parameter is that maybe you want to be able to simply use these views in a URLconf and specify the
current_appthat way? Further investigation is likely required.