Я сейчас перевожу свое приложение Django 1.11 на Django 2.1.У меня есть пользовательская модель пользователя:
from authtools.models import AbstractEmailUser, UserManager
from django.db import models
from django.utils.translation import ugettext_lazy as _
from model_utils.fields import AutoLastModifiedField
from model_utils.models import SoftDeletableModel
from core.behaviors import UniversallyUniqueIdentifiable
class User(
UniversallyUniqueIdentifiable,
SoftDeletableModel,
AbstractEmailUser
):
"""
User should generally not be deleted, but rather is_removed should just
be set to true. The delete() method is overwritten in the
SoftDeletableModel.
Also add a uuid field to avoid displaying the sequential primary key.
"""
name = models.CharField(_('name'), max_length=255, blank=True)
modified = AutoLastModifiedField(_('modified'))
objects = UserManager()
И пользовательский администратор:
from authtools.admin import (BASE_FIELDS, SIMPLE_PERMISSION_FIELDS,
NamedUserAdmin)
from django.contrib import admin
from .models import User
def verified(obj):
email = obj.emailaddress_set.filter(primary=True)
if email.exists():
return email[0].verified
return False
verified.boolean = True
@admin.register(User)
class SoftDeletableNamedUserAdmin(NamedUserAdmin):
"""
Overwrite the fields of the NamedUserAdmin to add is_removed.
"""
date_hierarchy = "date_joined"
list_display = (
'email',
'name',
verified,
'is_active',
'is_removed',
)
search_fields = ["email", "name"]
readonly_fields = ("date_joined", "modified")
fieldsets = (
BASE_FIELDS,
SIMPLE_PERMISSION_FIELDS,
("Contact information", {
"fields": (
("email", "name"),
)
}),
("Account information", {
"fields": (
"is_removed",
),
}),
("Dates", {
"fields": (
("date_joined", "modified",),
),
})
)
list_filter = ('is_active', 'is_removed',)
Проблема заключается в том, что при запуске сервера появляется следующая ошибка:
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
<class 'accounts.admin.SoftDeletableNamedUserAdmin'>: (admin.E012) There are duplicate field(s) in 'fieldsets[2][1]'.
<class 'accounts.admin.SoftDeletableNamedUserAdmin'>: (admin.E012) There are duplicate field(s) in 'fieldsets[3][1]'.
<class 'accounts.admin.SoftDeletableNamedUserAdmin'>: (admin.E012) There are duplicate field(s) in 'fieldsets[4][1]'.
Я посмотрел документацию , чтобы увидеть, изменились ли способы определения этих кортежей, но я не смог определить разницу.Что здесь не так?