Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| # -*- coding: utf-8 -*- | |
| from __future__ import unicode_literals | |
| import uuid | |
| from django.db import migrations, models | |
| def fill_mymodel_uuid(apps, schema_editor): | |
| db_alias = schema_editor.connection.alias | |
| MyModel = apps.get_model('myapp', 'MyModel') |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!