I read about creating user groups, I think I have the general idea.
For insta开发者_StackOverflow中文版nce if I have these two statement:
customer_group= Group(name='Customer')
customer_group.save()
Where in my django Project should I include the above statement to define the customer_group?
I believe you should just create one such group through admin
or through django shell
. You don't want to create multiple Customer groups, right?
To programmatically create groups and minimize the manual part of the process, you can use fixtures (deprecated as of version 1.7), migrations (as of version 1.7) or a post_syncdb signal to populate the database. I chose the later, and posted details on how to use a post_syncdb signal to populate Django security groups. The upshot of this is that any time that your application's syncdb
command is run the groups will be created.
精彩评论