Skip to content

Instantly share code, notes, and snippets.

@xoxwgys56
Created June 22, 2022 03:09
Show Gist options
  • Save xoxwgys56/fd9fc9f5ac6d2e216956ec1a768433c8 to your computer and use it in GitHub Desktop.
Save xoxwgys56/fd9fc9f5ac6d2e216956ec1a768433c8 to your computer and use it in GitHub Desktop.
django populate data for testing
#!/bin/sh
# use this line. if you want interact with terminal
#
# docker-compose exec web python3 manage.py createsuperuser --username "admin" --email "admin@example.com"
# populate data for testing
#
# NOTE below code affect indent
docker-compose exec web sh -c "
echo '
from django.contrib.auth.models import User
username = \"admin\"
email = \"admin@example.com\"
password = \"password\"
User.objects.create_superuser(username, email, password)
# import model to populate
' | python manage.py shell
"
@xoxwgys56
Copy link
Author

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment