chore: первый апдейт
This commit is contained in:
1 parent
a53fffdb59
commit
136894a376
11 files changed
+183
-11
No files matched your search
+30
-1
@@ -1 +1,30 @@
|
||||
# Register your models here.
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from django.contrib.auth.forms import AdminUserCreationForm, UserChangeForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .models import User
|
||||
|
||||
|
||||
class UserCreationForm(AdminUserCreationForm):
|
||||
class Meta(AdminUserCreationForm.Meta):
|
||||
model = User
|
||||
|
||||
|
||||
class UserEditForm(UserChangeForm):
|
||||
class Meta(UserChangeForm.Meta):
|
||||
model = User
|
||||
|
||||
|
||||
@admin.register(User)
|
||||
class UserAdmin(BaseUserAdmin):
|
||||
form = UserEditForm
|
||||
add_form = UserCreationForm
|
||||
fieldsets = (
|
||||
(None, {'fields': ('username', 'password')}),
|
||||
(_('Personal info'), {'fields': ('first_name', 'last_name')}),
|
||||
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions')}),
|
||||
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
||||
)
|
||||
list_display = ('username', 'first_name', 'last_name', 'is_staff')
|
||||
search_fields = ('username', 'first_name', 'last_name')
|
||||
Reference in new issue
Block a user