from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import AbstractUser from django.utils.translation import ugettext as _ from .models import User class ExtendedUserAdmin(UserAdmin): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) base_fields = [field.name for field in AbstractUser._meta.fields] all_fields = [field.name for field in self.model._meta.fields] extra_fields = [ f for f in all_fields if f not in base_fields and f != self.model._meta.pk.name ] self.fieldsets += ( (_('Champs additionnels'), {'fields': extra_fields}), ) admin.site.register(User, ExtendedUserAdmin)