-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This enables viewing users in Admin Panel and protects password from accidental change.
- Loading branch information
1 parent
5a38ba5
commit 7b656e6
Showing
1 changed file
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
# from django.contrib import admin #noqa: ERA001 | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin | ||
|
||
# Register your models here. | ||
from users.models import User | ||
|
||
FieldsetsType = tuple[tuple[None, dict[str, str | tuple[str]]]] | ||
|
||
|
||
@admin.register(User) | ||
class CustomUserAdmin(DjangoUserAdmin): | ||
list_display: list[str] = DjangoUserAdmin.list_display[1:] | ||
ordering: tuple[str] = ("email",) | ||
fieldsets: FieldsetsType = () | ||
add_fieldsets: FieldsetsType = ( | ||
( | ||
None, | ||
{ | ||
"classes": ("wide",), | ||
"fields": ( | ||
"email", | ||
"first_name", | ||
"last_name", | ||
"password1", | ||
"password2", | ||
), | ||
}, | ||
), | ||
) |