【Django】依赖auth.user的数据库迁移,以及admin用户非交互式创建

时间:2023-12-18 23:25:20

admin用户非交互式创建:

echo "from django.contrib.auth.models import User; User.objects.create_superuser('myadmin', 'myemail@example.com', 'hunter2')" | python manage.py shell

依赖auth.user的数据库迁移:

python manage.py migrate auth
python manage.py migrate

参考资料:

http://*.com/questions/1466827/automatically-create-an-admin-user-when-running-djangos-manage-py-syncdb

http://*.com/questions/29689365/auth-user-error-with-django-1-8-and-syncdb-migrate