This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://djangosnippets.org/snippets/2283/ | |
from django.db import transaction | |
from django.db.models import get_models, Model | |
from django.contrib.contenttypes.generic import GenericForeignKey | |
@transaction.atomic | |
def merge_model_objects(primary_object, alias_objects=None, keep_old=False): | |
""" | |
Use this function to merge model objects (i.e. Users, Organizations, Polls, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Convert camel-case to snake-case in python. | |
e.g.: CamelCase -> snake_case | |
e.g.: snake_case -> CamelCase | |
e.g.: CamelCase -> dash-case | |
e.g.: dash-case -> CamelCase | |
By: Jay Taylor [@jtaylor] | |
Me<modifier>: Yahya Kacem <fuj.tyoli@gmail.com> | |
Original gist: https://gist.github.com/jaytaylor/3660565 |