I’m creating a my own custom User model by extending the User model provided by the framework. I also created several model classes and included permissions as per below:
class Meta:
permissions = (("update_values", "update values"),)
When I do syncdb, I’m able to see all the permissions populating as they should. My question is, is there a way to associate these permissions with groups as well while syncdb is happening? Right now all of the examples i’m seeing are only if we do it by code, but some groups I want auto generated. Thanks for the help!
[EDIT]
I’m trying to load the initial data by creating a file called initial_data.json as per below:
[
{
"model": "django.contrib.auth.models.Group",
"pk": 1,
"fields": {
"name": "uni_admin"
}
},
{
"model": "django.contrib.auth.models.Group",
"pk": 2,
"fields": {
"name": "uni_poweruser"
}
},
{
"model": "django.contrib.auth.models.Group",
"pk": 3,
"fields": {
"name": "uni_viewer"
}
}
]
When I run python manage.py loaddata app/fixtures/initial_data.json, I keep getting DeserializationError: Invalid model identifier: 'django.contrib.auth.models.Group'…but isn’t that the correct model?
You could do it using fixtures or custom SQL (cf https://docs.djangoproject.com/en/dev/howto/initial-data/), but if you’re using South to manage your schema updates a “data migration” is IMHO a much cleaner solution (and if you’re not using South yet, you should – it really makes life much more easier).