How to quickly reset Django DB after changes?

2.9k Views Asked by At

I'm often experimenting around creating different models, changing relations and so forth. This usually happens when starting a new project. At this phase I do not want to create any migrations but instead just get the thing up and running. So i very often do this:

rm db.sqlite3
rm -r project/apps/app/migrations/*   
python manage.py makemigrations app
python manage.py migrate app   
python manage.py createsuperuser
bla
bla

Is there any way to have this "reset" function more quickly? I frustratingly found out, that django does not allow superusers to be created by a shell script.

Is there any way to purge the db without removing the users? How do you do this?

1

There are 1 best solutions below

2
Ramlakhan Kevat On

Try this:

Reset the Whole Database in Django

python manage.py flush

Reset an App Database Tables in Django

python manage.py migrate MyApp zero