From 5fcdeb60d59cd3979828afc83a432b1bd9b5d159 Mon Sep 17 00:00:00 2001 From: Sajeyks Date: Tue, 6 Oct 2026 20:24:57 +0300 Subject: [PATCH] Fix aldryn-categories admin with treebeard 7 treebeard 7 renamed the move form fields to treebeard_position and treebeard_ref_node; the category add form raised FieldError. --- dynamicweb/compat.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dynamicweb/compat.py b/dynamicweb/compat.py index c504779c..07d9a5f2 100644 --- a/dynamicweb/compat.py +++ b/dynamicweb/compat.py @@ -87,3 +87,16 @@ class CompatConfig(AppConfig): return response BasePageAdmin.changelist_view = changelist_view_with_cl + + # django-treebeard 7 renamed the form fields "_position" and + # "_ref_node_id" to "treebeard_position" and "treebeard_ref_node"; + # aldryn-categories still lists the old names in its admin. + from aldryn_categories.admin import CategoryAdmin + from parler.admin import TranslatableAdmin + + CategoryAdmin.fieldsets = ( + (None, {'fields': ('name', 'slug')}), + (' ', {'fields': ('treebeard_position', 'treebeard_ref_node')}), + ) + CategoryAdmin.get_form = lambda self, request, obj=None, **kwargs: ( + TranslatableAdmin.get_form(self, request, obj, **kwargs))