Skip to content

Fix: Display raw username in LogEvent admin when user is None (#337) - #338

Merged
jheld merged 1 commit into
soynatan:masterfrom
Mohammed2372:fix/337-display-raw-username
Jan 31, 2026
Merged

Fix: Display raw username in LogEvent admin when user is None (#337)#338
jheld merged 1 commit into
soynatan:masterfrom
Mohammed2372:fix/337-display-raw-username

Conversation

@Mohammed2372

Copy link
Copy Markdown
Contributor

Description

This PR fixes issue #337 where the "User name" column in the LoginEvent admin list appears empty for failed login attempts when the user does not exist.

Previously, get_username returned None if the user object was missing. I have updated the logic to fall back to the raw obj.username stored in the log event, ensuring the attempted username is always visible.

Changes

  • Modified LoginEventAdmin.get_username in easyaudit/admin.py.
  • If self.get_user(obj) returns None (e.g., failed login with invalid user), the method now returns obj.username.

Testing

  • Ran pytest locally (All tests passed).
  • Verified manually in the Django Admin panel.
  • Confirmed consistent behavior on my local environment (Windows/Git Bash).

@jheld
jheld merged commit e535fdb into soynatan:master Jan 31, 2026
0 of 15 checks passed
@Mohammed2372
Mohammed2372 deleted the fix/337-display-raw-username branch January 31, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants