Create initial example db from a separate python file.

This commit is contained in:
Adam Kelly 2020-02-24 16:16:49 +00:00
parent 592c2b7dfd
commit c1cf211d00
2 changed files with 11 additions and 8 deletions

10
init_db.py Normal file
View file

@ -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')

View file

@ -21,12 +21,5 @@ fi
python manage.py makemigrations fedireads python manage.py makemigrations fedireads
python manage.py migrate python manage.py migrate
echo "from fedireads.models import User python manage.py shell < init_db.py
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 runserver python manage.py runserver