Skip to content

Instantly share code, notes, and snippets.

@d2rk
Created September 27, 2016 09:15
Show Gist options
  • Save d2rk/1fc4c455ae40317553882c37cde337cf to your computer and use it in GitHub Desktop.
Save d2rk/1fc4c455ae40317553882c37cde337cf to your computer and use it in GitHub Desktop.
Flush Django database (postgresql)
from django.db import connection
from django.core.management import call_command
cursor = connection.cursor()
cursor.execute("DROP SCHEMA public CASCADE;")
cursor.execute("CREATE SCHEMA public;")
call_command('migrate')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment