Skip to content

Issue: 'coroutine' object has no attribute 'headers' in Middleware #27

Locked Answered by MEHRSHAD-MIRSHEKARY
ARYAN-NIKNEZHAD asked this question in Q&A
Discussion options

You must be logged in to vote

You're right—since Django 3.1+, middleware can be synchronous or asynchronous, and if get_response is asynchronous, it must be awaited. The error 'coroutine' object has no attribute 'headers' suggests that get_response is returning a coroutine rather than an HttpResponse, likely because an async view is being processed.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ARYAN-NIKNEZHAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working invalid This doesn't seem right
2 participants