Coverage for accounts/admin.py: 100.00%

13 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-16 12:21 -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 

10class CustomUserAdmin(UserAdmin): 

11 add_form = CustomUserCreationForm 

12 form = CustomUserChangeForm 

13 model = User 

14 list_display = [ 

15 "email", 

16 "username", 

17 "is_staff", 

18 ] 

19 """ 

20 fieldsets = UserAdmin.fieldsets 

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

22 "age", 

23 "country", 

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 

59admin.site.register(User, CustomUserAdmin)