我创建了一个自定义User类和一个自定义UserAdmin / Form类。一切都很好,但我仍然缺少groups
字段(auth_group)。
我不知道字段名称。
https://gist.github.com/CoinBR/c49c05f24bd5dcd3b4d4f2d205143a2e
Django版本:1.10
答案 0 :(得分:2)
您可以在PermissionsMixin
课程内看到:
"""
A mixin class that adds the fields and methods necessary to support
Django's Group and Permission model using the ModelBackend.
"""
...
groups = models.ManyToManyField(
Group,
verbose_name=_('groups'),
blank=True,
help_text=_(
'The groups this user belongs to. A user will get all permissions '
'granted to each of their groups.'
),
related_name="user_set",
related_query_name="user",
)
...
所以它的名字是groups
。您必须在UserCreateForm
字段和UserAdmin
字段集中添加它。