From 99f727e685c1fc30fb8f86387e306b46cd4f3dc0 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 21 Jan 2026 12:41:59 -0800 Subject: [PATCH] fix migration --- netbox/dcim/migrations/0226_modulebay_rebuild_tree.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py b/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py index 840215335..45d860129 100644 --- a/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py +++ b/netbox/dcim/migrations/0226_modulebay_rebuild_tree.py @@ -1,13 +1,19 @@ from django.db import migrations +import mptt +import mptt.managers def rebuild_mptt(apps, schema_editor): """ - Rebuild the MPTT tree for ModuleBay to apply new ordering by 'name' + Rebuild the MPPT tree for ModuleBay to apply new ordering by 'name' instead of 'module'. """ ModuleBay = apps.get_model('dcim', 'ModuleBay') - ModuleBay.objects.rebuild() + manager = mptt.managers.TreeManager() + manager.model = ModuleBay + mptt.register(ModuleBay) + manager.contribute_to_class(ModuleBay, 'objects') + manager.rebuild() class Migration(migrations.Migration):