Skip to content
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
This repository was archived by the owner on Aug 13, 2026. It is now read-only.

RequestMiddleware not working at Django 4.1 #677

Closed

Description

@tokibito

I tryed to use google.cloud.logging_v2.handlers.middleware.RequestMiddleware at Django 4.1.3, Python 3.10 but errors raises bellow:

Environment details

  • OS type and version: Linux
  • Python version: 3.10
  • pip version: pip-22.3.1
  • google-cloud-logging version: 3.2.5

Steps to reproduce

  1. Create new Django project.
  2. Add the RequestMiddleware to settings.MIDDLEWARE
  3. start runserver
  4. access / path --> error raised.

Code example

# settings.py at Django
MIDDLEWARE = [
    'google.cloud.logging_v2.handlers.middleware.RequestMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

Stack trace

Traceback (most recent call last):
  File "/home/vagrant/tmp/myproject/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/vagrant/tmp/myproject/venv/lib/python3.10/site-packages/django/utils/deprecation.py", line 131, in __call__
    if self._is_coroutine:
AttributeError: 'RequestMiddleware' object has no attribute '_is_coroutine'

At the same code, when using Django 4.0.8, it's working.

Activity

  1. daniel-sanche commented on Nov 29, 2022

    @daniel-sanche
    Contributor

    This should be fixed by this recent PR, which will soon be released as v3.3.0

    I just did a quick test with Django 4.1.3, and didn't run into any issues. Please re-open it if you still have problems after the 3.3.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the googleapis/python-logging API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions