def backward(apps, schema_editor):
    MyModel = apps.get_model('myapp', 'MyModel')
while condition:
    instance = MyModel.objects.get(myargs)
instance.delete()


class Migration(migrations.Migration):
    dependencies = [('myapp', '0003_auto_20150918_1153')]
operations = [migrations.RunPython(forward, backward)]
django migrations - workflow with multiple dev branches