Answer the question
In order to leave comments, you need to log in
How to return default User password display in Django admin?
Good afternoon
Added additional fields for the user through AbstractUser
class User(AbstractUser):
llcname = models.CharField('Наименование организации', max_length=50, blank=True)
llctin = models.CharField('ИНН', max_length=12, blank=True)
llccity = models.CharField('Город', max_length=30, blank=True)
llctel = models.CharField('Телефон', max_length=30, blank=True)
class UserAdmin(admin.ModelAdmin):
list_display = ('username', 'last_name', 'first_name', 'llcname', 'llctin', 'is_active')
fields = (
'username',
('last_name', 'first_name'),
('llcname', 'llctin'), ('llctel', 'llccity'),
'email', 'password',
('is_superuser', 'is_staff', 'is_active'),
('date_joined', 'last_login'),
'groups'
)
admin.site.register(User, UserAdmin)
Answer the question
In order to leave comments, you need to log in
In the admin.py file, inherit the UserAdmin class from the UserAdmin module django.contrib.auth.admin
from django.contrib.auth.admin import UserAdmin
class UserAdmin(UserAdmin):
list_display = ('username', 'last_name', 'first_name', 'llcname', 'llctin', 'is_active')
fields = (
'username',
('last_name', 'first_name'),
('llcname', 'llctin'), ('llctel', 'llccity'),
'email', 'password',
('is_superuser', 'is_staff', 'is_active'),
('date_joined', 'last_login'),
'groups'
)
admin.site.register(User, UserAdmin)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question