Skip to content

Instantly share code, notes, and snippets.

View davidlesieur's full-sized avatar

David Lesieur davidlesieur

View GitHub Profile
@smcoll
smcoll / django_migration_pk_to_uuid.py
Last active July 19, 2024 19:54
Django migration converting integer pk table to UUID pk table
# -*- 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')
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!