Skip to content

Commit

Permalink
Added user model to Django Admin
Browse files Browse the repository at this point in the history
This enables viewing users in Admin Panel and protects password from accidental change.
  • Loading branch information
bartczak-pa committed May 14, 2024
1 parent 5a38ba5 commit 7b656e6
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions users/admin.py
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",
),
},
),
)

0 comments on commit 7b656e6

Please sign in to comment.