mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-22 11:38:45 -06:00
fix migration
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
import mptt
|
|
||||||
import mptt.managers
|
import mptt.managers
|
||||||
|
import mptt.models
|
||||||
|
|
||||||
|
|
||||||
def rebuild_mptt(apps, schema_editor):
|
def rebuild_mptt(apps, schema_editor):
|
||||||
"""
|
"""
|
||||||
Rebuild the MPTT tree for ModuleBay to apply new ordering by 'name'
|
Rebuild the MPTT tree for ModuleBay to apply new ordering.
|
||||||
instead of 'module'.
|
|
||||||
"""
|
"""
|
||||||
ModuleBay = apps.get_model('dcim', 'ModuleBay')
|
ModuleBay = apps.get_model('dcim', 'ModuleBay')
|
||||||
|
|
||||||
@@ -14,11 +13,10 @@ def rebuild_mptt(apps, schema_editor):
|
|||||||
class MPTTMeta:
|
class MPTTMeta:
|
||||||
order_insertion_by = ('module', 'name',)
|
order_insertion_by = ('module', 'name',)
|
||||||
|
|
||||||
ModuleBay.MPTTMeta = MPTTMeta
|
ModuleBay._mptt_meta = mptt.models.MPTTOptions(MPTTMeta, ModuleBay)
|
||||||
|
|
||||||
manager = mptt.managers.TreeManager()
|
manager = mptt.managers.TreeManager()
|
||||||
manager.model = ModuleBay
|
manager.model = ModuleBay
|
||||||
mptt.register(ModuleBay)
|
|
||||||
manager.contribute_to_class(ModuleBay, 'objects')
|
manager.contribute_to_class(ModuleBay, 'objects')
|
||||||
manager.rebuild()
|
manager.rebuild()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user