From 5e4ce6713bd9383fc0abb23043b06bd691195f00 Mon Sep 17 00:00:00 2001 From: Sajeyks Date: Tue, 6 Oct 2026 13:56:47 +0300 Subject: [PATCH] Adapt to Django 6.1: compat app config, django.contrib.postgres --- dynamicweb/compat.py | 17 +++++++++++++++++ dynamicweb/settings/base.py | 2 ++ 2 files changed, 19 insertions(+) diff --git a/dynamicweb/compat.py b/dynamicweb/compat.py index 5bc3d9be..dd1135e7 100644 --- a/dynamicweb/compat.py +++ b/dynamicweb/compat.py @@ -55,3 +55,20 @@ if not hasattr(models, 'NullBooleanField'): if not hasattr(HttpRequest, 'is_ajax'): HttpRequest.is_ajax = lambda self: self.headers.get('x-requested-with') == 'XMLHttpRequest' + + +from django.apps import AppConfig + + +class CompatConfig(AppConfig): + """Shims that need the app registry; listed first in INSTALLED_APPS so + they are in place before the admin modules of other apps are imported.""" + name = 'dynamicweb' + label = 'dynamicweb_compat' + + def ready(self): + from django.contrib.admin import options + from django.contrib.auth import admin as auth_admin + + if not hasattr(auth_admin, 'csrf_protect_m'): + auth_admin.csrf_protect_m = options.csrf_protect_m diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 70bc0921..e2aa7708 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -92,6 +92,7 @@ if not SECRET_KEY: # Application definition INSTALLED_APPS = ( + 'dynamicweb.compat.CompatConfig', # 1st migrate 'membership', 'djangocms_admin_style', @@ -103,6 +104,7 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', + 'django.contrib.postgres', 'multisite', 'easy_thumbnails', 'utils',