Skip to content

Instantly share code, notes, and snippets.

@burhan
Last active August 10, 2016 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burhan/2704588 to your computer and use it in GitHub Desktop.
Save burhan/2704588 to your computer and use it in GitHub Desktop.
django "one liner" to delete all tables installed and reset the db
echo 'from django.conf import settings; print settings.INSTALLED_APPS; quit();' | \
python manage.py shell --plain 2>&1 | \
tail -n1 | sed -r "s|^.*\((.*)\).*$|\1|; s|[',]| |g; s|django\.contrib\.||g" | \
xargs python manage.py sqlclear | \
python manage.py dbshell && python manage.py migrate --run-syncdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment