'How to quickly reset Django DB after changes?
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?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ramlakhan Kevat |
