MT#58450 Support and use django-structlog versions >=6.0

As of django-structlog v6.0.0, our django application fails with:

| Traceback (most recent call last):
|   File "/var/lib/repoapi/venv_prod/lib/python3.9/site-packages/django/utils/module_loading.py", line 20, in import_string
|     return getattr(module, class_name)
| AttributeError: module 'django_structlog.middlewares' has no attribute 'CeleryMiddleware'

Quoting from
https://django-structlog.readthedocs.io/en/latest/upgrade_guide.html#upgrading-to-6-0:

| (If you use celery) Make sure you use DJANGO_STRUCTLOG_CELERY_ENABLED = True
|
| It is only applicable if you use celery integration.
|
| django_structlog.middlewares.CeleryMiddleware has been remove in favor of a django settings.
|
| MIDDLEWARE += [
|     "django_structlog.middlewares.RequestMiddleware",
|     # "django_structlog.middlewares.CeleryMiddleware",  # <- remove this
| ]
|
| DJANGO_STRUCTLOG_CELERY_ENABLED = True # <-- add this

Instead of forcing usage of an older django-structlog version,
let's make sure we have 6.0 or newer and update configuration
accordingly.

Change-Id: I0449c05db682ace22438b8b0ad8d8a4a1dfca71a
master
Michael Prokop 2 years ago
parent 2556480954
commit ebd9601fe2

@ -60,9 +60,10 @@ MIDDLEWARE = (
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django_structlog.middlewares.RequestMiddleware",
"django_structlog.middlewares.CeleryMiddleware",
)
DJANGO_STRUCTLOG_CELERY_ENABLED = True
ROOT_URLCONF = "repoapi.urls"
LOGIN_URL = "rest_framework:login"
LOGOUT_URL = "rest_framework:logout"

@ -10,7 +10,7 @@ django-extensions
django-filter
django-import-export>=3.0
django-jsonify
django-structlog
django-structlog>=6.0
django-timezone-field
djangorestframework>=3.6
djangorestframework-api-key==2.*

Loading…
Cancel
Save