[Answered ]-Searching by Username field in Django admin

2👍

You can do this by adding following in your admin.py file.

class WebUser(User):

    class Meta:
        proxy = True
        verbose_name = "User"
        verbose_name_plural = "Users"


class UserAdmin(admin.ModelAdmin):
    search_fields = ('user__username', 'user__email')

admin.site.register(WebUser, UserAdmin)

Hope this will help.

Leave a comment