django-check-seo
django-check-seo copied to clipboard
<asgiref.local.Local object at 0xffff8cab4f90> object has no attribute 'request'
I'm not sure if this is a django-check-seo issue or a django-simple-history issue. But if I enable the middleware of django-simple-history, it breaks django-check-seo. Either work fine independently but not together so there seems to be a conflict somewhere.
To reproduce the bug, install both apps, and the django-check-seo. Here's the traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:9000/django-check-seo/?page=/
Django Version: 4.2.4
Python Version: 3.11.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.sitemaps',
'django_bootstrap5',
'compressor',
'storages',
'cities_light',
'simple_history',
'django_cleanup.apps.CleanupConfig',
'django_celery_beat',
'django_check_seo',
'linkcheck']
Installed Middleware:
['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',
'csp.middleware.CSPMiddleware',
'simple_history.middleware.HistoryRequestMiddleware',]
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/simple_history/middleware.py", line 37, in middleware
with _context_manager(request):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/contextlib.py", line 144, in __exit__
next(self.gen)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/simple_history/middleware.py", line 16, in _context_manager
del HistoricalRecords.context.request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/asgiref/local.py", line 120, in __delattr__
raise AttributeError(f"{self!r} object has no attribute {key!r}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: AttributeError at /django-check-seo/
Exception Value: <asgiref.local.Local object at 0xffff8cab4f90> object has no attribute 'request'
Hi, I'll take a look :)
Took a look, here's my conclusion.
Should be fixed by https://github.com/jazzband/django-simple-history/pull/1256 (available in django-simple-history 3.5.0) :)