Coverage for accounts/admin.py: 100.00%

13 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-02 19:56 -0700

1from django.contrib import admin 

2from django.contrib.auth import get_user_model 

3from django.contrib.auth.admin import UserAdmin 

4 

5from .forms import CustomUserChangeForm, CustomUserCreationForm 

6 

7User = get_user_model() 

8 

9 

10@admin.register(User) 

11class CustomUserAdmin(UserAdmin): 

12 add_form = CustomUserCreationForm 

13 form = CustomUserChangeForm 

14 model = User 

15 list_display = [ 

16 "email", 

17 "username", 

18 "is_staff", 

19 ] 

20 """ 

21 fieldsets = UserAdmin.fieldsets 

22 fieldsets[1][1]["fields"] = fieldsets[1][1]["fields"] + ( 

23 "age", 

24 "country", 

25 "profile_pic", 

26 "bio", 

27 ) 

28 """ 

29 fieldsets = ( 

30 (None, {"fields": ("username", "password")}), 

31 ( 

32 "Personal information", 

33 { 

34 "fields": ( 

35 "first_name", 

36 "last_name", 

37 "email", 

38 "age", 

39 "country", 

40 "profile_pic", 

41 "bio", 

42 ) 

43 }, 

44 ), 

45 ( 

46 "Permissions", 

47 { 

48 "fields": ( 

49 "is_active", 

50 "is_staff", 

51 "is_superuser", 

52 "groups", 

53 "user_permissions", 

54 ) 

55 }, 

56 ), 

57 ("Important dates", {"fields": ("last_login", "date_joined")}), 

58 ) 

59 

60 

61# admin.site.register(User, CustomUserAdmin)