How to drop all tables from the database with manage.py CLI in Django?
As far as I know there is no management command to drop all tables. If you don't mind hacking Python you can write your own custom command to do that. You may find the sqlclear
option interesting. Documentation says that ./manage.py sqlclear
Prints the DROP TABLE SQL statements for the given app name(s).
Update: Shamelessly appropriating @Mike DeSimone's comment below this answer to give a complete answer.
./manage.py sqlclear | ./manage.py dbshell
As of django 1.9 it's now ./manage.py sqlflush
There's no native Django management command to drop all tables. Both sqlclear
and reset
require an app name.
However, you can install Django Extensions which gives you manage.py reset_db
, which does exactly what you want (and gives you access to many more useful management commands).