How do I delete DB (sqlite3) in Django 1.9 to start from scratch?
rm -f tmp.db db.sqlite3
rm -r my-app/migrations
python manage.py makemigrations
python manage.py migrate
Removes the database.
Removes the migrations from your app.
Re-runs the migrations. Note: you could also do: python manage.py makemigrations my-app
Migrate changes.
- Delete the sqlite database file (often
db.sqlite3
) in your django project folder (or wherever you placed it) - Delete everything except
__init__.py
file frommigration
folder in all django apps (eg:rm */migrations/0*.py
) - Make changes in your models (
models.py
). - Run the command
python manage.py makemigrations
orpython3 manage.py makemigrations
- Then run the command
python manage.py migrate
.
That's all.
If your changes to the models are not detected by makemigrations
command, please check this answer