ERRORS:
<class 'accounts.admin.CustomUserAdmin'>: (admin.E012) There are duplicate field(s) in 'fieldsets[4][1]'.
System check identified 1 issue (0 silenced).
^C%
~/Projects/Python/CRAFTMINE/web │ main !8 ?1 ✔ │ 25m 24s │ 10:44:26
~/Projects/Python/CRAFTMINE/web │ main !8 ?1 python3 manage.py runserver INT ✘ │ 10:44:26
Watching for file changes with StatReloader
Performing system checks...
File "/home/stevek/.local/lib/python3.9/site-packages/django/core/management/base.py", line 469, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
<class 'accounts.admin.CustomUserAdmin'>: (admin.E012) There are duplicate field(s) in 'fieldsets[4][1]'.
我收到此错误,但不知道出了什么问题。我的 admin.py 显示
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .forms import PlayerCreationForm, PlayerChangeForm
from .models import Player
class CustomUserAdmin(UserAdmin):
add_form = PlayerCreationForm
form = PlayerChangeForm
model = Player
list_display = ['email', 'username', 'password',]
fieldsets = UserAdmin.fieldsets + (
(None, {'fields': ('email', 'username', 'password',)}),
)
add_fieldsets = UserAdmin.add_fieldsets + (
(None, {'fields': ('email', 'username', 'password',)}),
)
admin.site.register(Player, CustomUserAdmin)
我对包括用户名和通行证在内的所有内容都使用了自定义字段集,因为我不希望 django 的用户/通行证限制注册。这也是正确的方法吗?