How to drop all tables from the database with 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 ./ sqlclear Prints the DROP TABLE SQL statements for the given app name(s).

Shamelessly appropriating @Mike DeSimone’s comment below this answer to give a complete answer.

./ sqlclear | ./ dbshell

As of django 1.9 it’s now ./ sqlflush

Leave a Comment