how to create default users on django init_data?

2019-06-28 01:32发布

How can I loaddata for default list of users, when I syncdb ?

1条回答
家丑人穷心不美
2楼-- · 2019-06-28 02:14

What I do.

  1. Create users manually.

  2. Do a dumpdata for the auth.users table.

  3. After doing syncdb, do a loaddata for the dumped users.

It's not totally "automatic" because -- in the long run -- totally automatic is a terrible idea. Most syncdb operations involve database changes that also require you preserve some legacy data, perhaps dropping tables, and doing other "schema migration" steps. Each time it involves something special. So "total automation" rarely works out well.

查看更多
登录 后发表回答