﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29132	update_last_login signal handler shouldn't be connected if User.last_login attribute isn't a field	Mikhail Porokhovnichenko	Mikhail Porokhovnichenko	"**Please note! It's not a  #26823 duplicate, and it's just an issue related this one.**

In the current implementation, a signal handler connects with a user model when this model has a `last_login` field.

{{{
#!python
if hasattr(get_user_model(), 'last_login'):
    from .models import update_last_login
    user_logged_in.connect(update_last_login, dispatch_uid='update_last_login')
}}}

And it would work when there isn't a `last_login` attribute in the custom user model. But what if I've inherited my custom model from `AbstractUser` and dropped the `last_login` by setting it to `None`? 

{{{
#!python
class User(AbstractBaseUser):
    last_login = None     # Drop ``last_login`` field off
}}}

Technically, the model has a `last_login` attribute, but it's not a field!

Suggesting change the check condition something like that:
{{{
#!python
last_login = getattr(get_user_model(), 'last_login', None)
if last_login is not None:
    # ...
}}}
or even 
{{{
#!python
if isisintance(last_login, models.Field):
    # ...
}}}
"	Bug	closed	contrib.auth	2.0	Normal	fixed	last_login, update_last_login, signals, user_logged_in		Ready for checkin	1	0	0	0	0	0
