Last active
March 27, 2018 15:43
-
-
Save VelociCopter/ed5096e5bdb111f1844c9ad3820961b4 to your computer and use it in GitHub Desktop.
Django Dev Notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To clear all DB entries and schema in a Django project backed with postgres/psql... | |
# -- OPTION 1: MANUAL –– | |
# Remove DB entries | |
python manage.py flush | |
# Remove all of the migration files | |
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete | |
find . -path "*/migrations/*.pyc" -delete | |
# Delete the db | |
rm db.sqlite3 | |
# –– OPTION 2: Django-Extensions –– | |
pipenv install django-extensions | |
pipenv shell | |
# Add 'django_extensions' to INSTALLED_APPS in settings.py | |
python manage.py reset_db | |
# –– FINALLY –– | |
# And you probably want to recreate it, but make sure your schema (*/models.py) is how you want it first | |
python manage.py makemigrations # should be no changes detected. If so, you probably didn't clear the db correctly | |
python manage.py migrate # should be a bunch of initial files | |
python manage.py createsuperuser # you'll probably want this, too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment