Last active
December 16, 2020 13:01
-
-
Save Alir3z4/ae10fc7416884b3fed76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from django.utils.translation import ugettext_lazy as _ | |
class MyUserAdmin(UserAdmin): | |
# The forms to add and change user instances | |
form = UserChangeForm | |
add_form = UserCreationForm | |
# The fields to be used in displaying the User model. | |
# These override the definitions on the base UserAdmin | |
# that reference specific fields on auth.User. | |
list_display = ('username', 'email', 'is_admin', 'is_active', 'aboutme', 'activation_key') | |
list_filter = ('is_admin',) | |
fieldsets = ( | |
(None, {'fields': ('username', 'password')}), | |
(_('Personal info'), {'fields': ('email', 'aboutme', 'activation_key')}), | |
(_('Permissions'), {'fields': ('is_admin', 'is_active')}), | |
) | |
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin | |
# overrides get_fieldsets to use this attribute when creating a user. | |
add_fieldsets = ( | |
(None, { | |
'classes': ('wide',), | |
'fields': ('username', 'email', 'password1', 'password2')} | |
), | |
) | |
search_fields = ('email', 'username') | |
ordering = ('email', 'username') | |
filter_horizontal = () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment