Skip to content

Commit

Permalink
admin: allow to edit user password
Browse files Browse the repository at this point in the history
  • Loading branch information
brmzkw committed Aug 17, 2023
1 parent df4e844 commit 2e76e92
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mesads/users/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django import forms
from django.contrib import admin
from django.contrib.auth.forms import UserChangeForm
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.db.models import Count
from django.urls import reverse
from django.utils.html import format_html
Expand Down Expand Up @@ -52,7 +54,7 @@ def queryset(self, request, queryset):
return queryset.filter(adsmanageradministrator_count=0)


class UserForm(forms.ModelForm):
class UserForm(UserChangeForm):
"""Override the default form to add a custom widget to the email field."""

class Meta:
Expand All @@ -62,7 +64,7 @@ class Meta:


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
class UserAdmin(BaseUserAdmin):
form = UserForm

list_display = (
Expand All @@ -78,8 +80,13 @@ class UserAdmin(admin.ModelAdmin):
ADSManagerAdministratorFilter,
)

fieldsets = []

ordering = ("email",)

fields = (
"email",
"password",
"date_joined",
"last_login",
"is_superuser",
Expand Down

0 comments on commit 2e76e92

Please sign in to comment.