[solved] custom User Model : I can't assign a user to a group in admin panel

hi !
I have created a custom User Model in my app. But, now, in the administration panel, I can’t assign a user to a group or a permission because the right table doesn’t appear. I don’t find any solution yet, do you have any idea to solve this problem ?

Thanks !

screens :

Codes :

class UserAdmin(admin.ModelAdmin):
    list_display = ('username', 'email')
    search_fields = ('username',)
    fieldsets = (
        (None, {
            'classes': ['wide'],
            'fields': ('username', 'password')
        ('Informations personnelles', {
            'classes': ['wide'],
            'fields': ('first_name', 'last_name', 'email', 'avatar')
        ('Permissions', {
            'classes': ['wide'],
            'fields': ('is_superuser', 'is_staff', 'is_active', 'groups', 'permissions')
        ('Dates importantes', {
            'classes': ['wide'],
            'fields': ('last_login', 'date_joined')

models.py :

class User(AbstractUser):
    signup_token = models.UUIDField(primary_key=False, unique=True, verbose_name="jeton d'inscription", null=True, blank=True)
    avatar = CloudinaryField('image', blank=True, null=True)

Finally, by dint of digging through the docs, I finally found it. For those interested, add this line to admin.py:
filter_horizontal = ('groups', 'user_permissions',)

Doc source : The Django admin site | Django documentation | Django

1 Like

Thank you for sharing :slightly_smiling_face::+1:

1 Like