Explorar o código

fix migration

Arthur hai 1 mes
pai
achega
99f727e685
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      netbox/dcim/migrations/0226_modulebay_rebuild_tree.py

+ 8 - 2
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):