From ef0bc180951a38fa1b9828755eb0e0cbe582b6c6 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 21 Jan 2026 12:47:16 -0800 Subject: [PATCH] fix migration --- netbox/dcim/migrations/0226_modulebay_rebuild_tree.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py b/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py index 45d860129..53f3cecff 100644 --- a/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py +++ b/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py @@ -5,10 +5,17 @@ import mptt.managers def rebuild_mptt(apps, schema_editor): """ - Rebuild the MPPT tree for ModuleBay to apply new ordering by 'name' + Rebuild the MPTT tree for ModuleBay to apply new ordering by 'name' instead of 'module'. """ ModuleBay = apps.get_model('dcim', 'ModuleBay') + + # Set MPTTMeta with the correct order_insertion_by + class MPTTMeta: + order_insertion_by = ('module', 'name',) + + ModuleBay.MPTTMeta = MPTTMeta + manager = mptt.managers.TreeManager() manager.model = ModuleBay mptt.register(ModuleBay)