djangodjango-admindjango-admin-toolsdjango-admin-actions

please help me for customizing my django admin pannel


i should add this tables in my admin class in django please help me i target image


Solution

  • I am not sure if you are trying to get the Group model or just Groups in the User model.

    To add Group in Admin you can do like this in admin.py file:

    from django.contrib import admin
    from django.contrib.auth import get_user_model
    from django.contrib.auth.models import Group
    
    User = get_user_model()
    
    admin.site.register(User)
    admin.site.register(Group)
    

    Or if you just want to add extra properties in User you can do like this in your UserAdmin class:

    fieldsets = (
        # ...
        ('Permissions', {'fields': ('groups', 'user_permissions')}),
    )
    

    and Update admin.site.register(User) line with

    admin.site.register(User, UserAdmin)