hi, when i use get_fieldsets, it destroy add user from.
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import gettext_lazy as _
from django.contrib import admin
from .forms import User, UserChangeForm, UserCreationForm
from .models import User
class UserAdmin(BaseUserAdmin):
ordering = ['username']
add_form = UserCreationForm
form = UserChangeForm
model = User
list_display = ['id', 'username', 'is_active', 'is_security', 'is_customer']
list_display_links = ['id', 'username']
list_filter = ['username', 'is_security', 'is_customer']
def get_fieldsets(self, request, *args, **kwargs):
if request.user.is_superuser:
return (
(None, {
'fields': (
'email', 'password', 'first_name', 'last_name', 'groups', 'is_active', 'is_superuser',
'is_staff', 'last_login', 'user_permissions',
),
}),
)
return (
(None, {
'fields': (
'first_name', 'last_name','password',
)
}),
)
admin.site.register(User, UserAdmin)
can anyone came across this problem?