﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34652	Async support in admin view - 'coroutine' object has no attribute 'has_header'	Olivier Martin	nobody	"I wanted to change one of my admin page to leverage async support.

I tried this simple example (based on the Django tutorial):

{{{
from django.contrib import admin

from .models import Question

class QuestionAdmin(admin.ModelAdmin):
	async def change_view(self, request, object_id, form_url='', extra_context=None):
		return super(QuestionAdmin, self).change_view(
            		request, object_id, form_url, extra_context=extra_context,
	        )
	
admin.site.register(Question, QuestionAdmin)
}}}

and started with runserver: `python3 ./mysite/manage.py runserver` and when accessing on the page:

{{{
Internal Server Error: /admin/polls/question/1/change/
Traceback (most recent call last):
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/core/handlers/exception.py"", line 55, in inner
    response = get_response(request)
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/core/handlers/base.py"", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/contrib/admin/options.py"", line 688, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/utils/decorators.py"", line 134, in _wrapper_view
    response = view_func(request, *args, **kwargs)
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/views/decorators/cache.py"", line 63, in _wrapper_view_func
    add_never_cache_headers(response)
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/utils/cache.py"", line 292, in add_never_cache_headers
    patch_response_headers(response, cache_timeout=-1)
  File ""/home/olivier/.local/lib/python3.10/site-packages/django/utils/cache.py"", line 283, in patch_response_headers
    if not response.has_header(""Expires""):
AttributeError: 'coroutine' object has no attribute 'has_header'
}}}

Note: same error when running in Daphne with asgi.

I read the Django Async doc https://docs.djangoproject.com/en/4.2/topics/async/#async-views and I could not see any restriction on using async in admin pages."	Bug	new	Uncategorized	4.2	Normal		async		Unreviewed	0	0	0	0	0	0
