Skip to content

Instantly share code, notes, and snippets.

@bofh19
Created June 28, 2013 20:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bofh19/5887902 to your computer and use it in GitHub Desktop.
Save bofh19/5887902 to your computer and use it in GitHub Desktop.
Django move your data to slave from default
# don't remember from where i got this
from django.contrib.contenttypes.models import ContentType
def run():
def do(Table):
if Table is not None:
table_objects = Table.objects.all()
for i in table_objects:
i.save(using='slave')
ContentType.objects.using('slave').all().delete()
for i in ContentType.objects.all():
do(i.model_class())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment