[Django]-How to display the last login date and time on the users list on the django admin site?

7👍

Admin.py:

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

class CustomUserAdmin(UserAdmin):
    list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff', 'last_login') # Added last_login

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)

Inherit from the main UserAdmin, do you customization, then unregister User then register it again with the Admin you created

Leave a comment