Coverage for accounts/admin.py: 100.00%

11 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-13 15:39 -0700

1from django.contrib.auth import get_user_model 

2from django.contrib.auth.admin import UserAdmin 

3 

4from .forms import CustomUserChangeForm, CustomUserCreationForm 

5 

6User = get_user_model() 

7 

8 

9class CustomUserAdmin(UserAdmin): 

10 add_form = CustomUserCreationForm 

11 form = CustomUserChangeForm 

12 model = User 

13 list_display = [ 

14 "email", 

15 "username", 

16 "is_staff", 

17 ] 

18 """ 

19 fieldsets = UserAdmin.fieldsets 

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

21 "age", 

22 "country", 

23 "profile_pic", 

24 "bio", 

25 ) 

26 """ 

27 fieldsets = ( 

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

29 ( 

30 "Personal information", 

31 { 

32 "fields": ( 

33 "first_name", 

34 "last_name", 

35 "email", 

36 "age", 

37 "country", 

38 "profile_pic", 

39 "bio", 

40 ) 

41 }, 

42 ), 

43 ( 

44 "Permissions", 

45 { 

46 "fields": ( 

47 "is_active", 

48 "is_staff", 

49 "is_superuser", 

50 "groups", 

51 "user_permissions", 

52 ) 

53 }, 

54 ), 

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

56 ) 

57 

58 

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