Skip to content

Instantly share code, notes, and snippets.

@Alir3z4
Last active December 16, 2020 13:01
Show Gist options
  • Save Alir3z4/ae10fc7416884b3fed76 to your computer and use it in GitHub Desktop.
Save Alir3z4/ae10fc7416884b3fed76 to your computer and use it in GitHub Desktop.
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