Coverage for accounts/admin.py: 100.00%

12 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-08 13:12 -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 = ( 

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

23 ( 

24 "Personal information", 

25 { 

26 "fields": ( 

27 "first_name", 

28 "last_name", 

29 "email", 

30 "age", 

31 "country", 

32 "profile_pic", 

33 "bio", 

34 ) 

35 }, 

36 ), 

37 ( 

38 "Permissions", 

39 { 

40 "fields": ( 

41 "is_active", 

42 "is_staff", 

43 "is_superuser", 

44 "groups", 

45 "user_permissions", 

46 ) 

47 }, 

48 ), 

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

50 )