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