mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
27 lines
619 B
Python
27 lines
619 B
Python
from django.db import migrations
|
|
import mptt
|
|
import mptt.managers
|
|
|
|
|
|
def rebuild_mptt(apps, schema_editor):
|
|
manager = mptt.managers.TreeManager()
|
|
InventoryItem = apps.get_model('dcim', 'InventoryItem')
|
|
manager.model = InventoryItem
|
|
mptt.register(InventoryItem)
|
|
manager.contribute_to_class(InventoryItem, 'objects')
|
|
manager.rebuild()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('dcim', '0118_inventoryitem_mptt'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(
|
|
code=rebuild_mptt,
|
|
reverse_code=migrations.RunPython.noop
|
|
),
|
|
]
|