I am using the method described in this question to load intial users for my django project.
This saves user permissions, where one permission record might look like this:
{
"pk": 56,
"model": "auth.permission",
"fields": {
"codename": "change_somemodel",
"name": "Can change some model",
"content_type": 19
}
And a user record:
{
"pk": 2,
"model": "auth.user",
"fields": {
"username": "some_user",
"first_name": "",
"last_name": "",
"is_active": true,
"is_superuser": false,
"is_staff": true,
"last_login": "2011-09-20 06:36:54",
"groups": [],
"user_permissions": [
10,
11,
19,
20,
21,
1,
2,
56,
...,
],
"password": "sha1$e4f29$fcec7f8bb930d98abdaaa3c0020220f413c4c1f5",
"email": "",
"date_joined": "2011-03-15 06:01:41"
}
Is there any potential for the content type foreign key to change on a future installation? How about if models or apps added? For example, let's say I add a model to my core app, then I have some reusable apps which are listed after that in settings.py, will those have a different content_type_id on a new installation? Can I include the content_type table in my initial data, or is that likely to cause other issues?
If this isn't a reliable method to load multiple initial users into the database, what are the alternatives?
Check Natural Keys
. Use -n w/ dumpdata, like ./manage.py dumpdata -n auth.User
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With