From c1cf211d003c62c63b497b77b79b3d08b210fc53 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Mon, 24 Feb 2020 16:16:49 +0000 Subject: [PATCH] Create initial example db from a separate python file. --- init_db.py | 10 ++++++++++ rebuilddb.sh | 9 +-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 init_db.py diff --git a/init_db.py b/init_db.py new file mode 100644 index 00000000..c112b5a7 --- /dev/null +++ b/init_db.py @@ -0,0 +1,10 @@ +from fedireads.models import User +from fedireads.openlibrary import get_or_create_book + +User.objects.create_user('mouse', 'mouse.reeve@gmail.com', 'password123') +User.objects.create_user('rat', 'rat@rat.com', 'ratword') + +User.objects.get(id=1).followers.add(User.objects.get(id=2)) + +get_or_create_book('OL1715344W') +get_or_create_book('OL102749W') diff --git a/rebuilddb.sh b/rebuilddb.sh index 127b5ed7..09d024aa 100755 --- a/rebuilddb.sh +++ b/rebuilddb.sh @@ -21,12 +21,5 @@ fi python manage.py makemigrations fedireads python manage.py migrate -echo "from fedireads.models import User -User.objects.create_user('mouse', 'mouse.reeve@gmail.com', 'password123')" | python manage.py shell -echo "from fedireads.models import User -User.objects.create_user('rat', 'rat@rat.com', 'ratword') -User.objects.get(id=1).followers.add(User.objects.get(id=2))" | python manage.py shell -echo "from fedireads.openlibrary import get_or_create_book -get_or_create_book('OL1715344W') -get_or_create_book('OL102749W')" | python manage.py shell +python manage.py shell < init_db.py python manage.py runserver