We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
➜ WePost (master) ✗ ./manage_dev.py makemigrations wepost_auth --empty --name create_dev_test_users Migrations for 'wepost_auth': wepost/apps/auth/migrations/0002_create_dev_test_users.py
# Generated by Django 2.2b1 on 2019-02-22 12:13 from django.db import migrations from wepost.apps.auth.models import WepostUser def create_dev_test_users(apps,schema_editor): dev_usernames = [ f"dev{i}" for i in range(20)] test_usernames = [ f"test{i}" for i in range(20)] usernames = dev_usernames + test_usernames users = [ ] for username in usernames: user = WepostUser(username=username, is_active=True,is_staff=username.startswith("dev")) user.set_password("abc123456") users.append(user) WepostUser.objects.bulk_create(users) class Migration(migrations.Migration): dependencies = [ ('wepost_auth', '0001_initial'), ] operations = [ migrations.RunPython(create_dev_test_users) ]
值得注意的是,创建用户时密码需要调用 set_password 来设置。
set_password
➜ WePost (master) ✗ ./manage_dev.py migrate wepost_auth Operations to perform: Apply all migrations: wepost_auth Running migrations: Applying wepost_auth.0002_create_dev_test_users… OK
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用数据库迁移脚本创建开发用户及测试用户
值得注意的是,创建用户时密码需要调用
set_password
来设置。The text was updated successfully, but these errors were encountered: