If the user model does not contain a username field (as is the case when using email addresses as usernames), referencing user.username results in an error. Since the username variable is already properly set to get_username() earlier in the function, it seems appropriate to use that variable for the authentication success message as well.
If the user model does not contain a
username
field (as is the case when using email addresses as usernames), referencinguser.username
results in an error. Since theusername
variable is already properly set toget_username()
earlier in the function, it seems appropriate to use that variable for the authentication success message as well.