How to delete all data for one app in Django 1.4 now that reset is gone?

Rory picture Rory · Jun 29, 2012 · Viewed 9k times · Source

How do I delete all the data in the database for on Django app? In previous version manage.py reset APPNAME did the job, but that's been deprecated.

What are we supposed to do now if we want to delete all the data from an app using the command line?

Answer

Chris Pratt picture Chris Pratt · Jun 29, 2012

reset and sqlreset were both just wrappers around other management commands. sqlreset in particular can be duplicate by simply running:

python manage.py sqlclear myapp
python manage.py sqlall myapp

reset only served to automatically run the result of sqlreset on the database. Personally, I think removing that is a fantastic idea. Still, if you want similar functionality, you can just pipe the output to your database's shell commands.

For PostgreSQL, for example:

python manage.py sqlclear myapp | psql mydatabase
python manage.py sqlall myapp | psql mydatabase