Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 884
Amandasaurus Avatar asked Jun 29 '12 17:06

Amandasaurus


People also ask

How delete all data Django?

If you want to remove all the data from all your tables, you might want to try the command python manage.py flush . This will delete all of the data in your tables, but the tables themselves will still exist.

How do I delete a record in Django?

To delete a record we do not need a new template, but we need to make some changes to the members template. Of course, you can chose how you want to add a delete button, but in this example, we will add a "delete" link for each record in a new table column. The "delete" link will also contain the ID of each record.


1 Answers

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
like image 165
Chris Pratt Avatar answered Oct 05 '22 12:10

Chris Pratt