我正在尝试使用 django Rest Framework 字段中的 MultipleChoiceField,如以下链接所述: https ://pypi.org/project/django-multiselectfield/
我的代码片段的一部分如下:
from rest_framework import fields
CHOICES = (
('publisher', 'Can Publish programs'),
('author', 'Can author programs')
)
class User(AbstractUser):
email = EmailField(verbose_name=_('email address'), unique=True)
edumap_roles = fields.MultipleChoiceField(choices=CHOICES, allow_blank=True)
但是,当我单击 email_addres 查看用户详细信息时,出现以下错误:
编辑:这是我的 UserAdmin 类
@register(User)
class UserAdmin(CustomAdmin):
"""Define admin model for custom User model with no email field."""
fieldsets = (
(None, {'fields': ('email', 'password')}),
(_('Personal info'), {'fields': ('first_name', 'last_name')}),
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser',
'groups', 'user_permissions', 'edumap_roles')}),
(_('Important dates'), {'fields': ('last_login', 'date_joined',
'created_at', 'updated_at')}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'password1', 'password2'),
}),
)
list_display = ('email', 'first_name', 'last_name', 'is_staff', 'edumap_roles')
search_fields = ('email', 'first_name', 'last_name')
ordering = ('email',)
readonly_fields = ['created_at', 'updated_at']
我的其余框架版本是:3.11.0。我想补充什么吗?