PasswordResetForm fails on custom user models without an is_active DB field
|Reported by:||Fraser Nevett||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The change made for ticket #21291 results in the standard
PasswordResetForm breaking if the custom user model being used doesn't have
is_active defined as a database field. It raises:
Cannot resolve keyword 'is_active' into field.
As far as I can tell from the docs and code, Django requires
is_active to be present on the custom user model as an attribute, not an actual database field.
In my case, I have
is_active defined as a property on the model that is calculated from other information.
The filtering of active users should therefore be done in Python rather than at the database-level. Instead of:
active_users = UserModel._default_manager.filter( email__iexact=email, is_active=True) for user in active_users:
It should be something like:
users = UserModel._default_manager.filter(email__iexact=email) active_users = filter(lambda u: u.is_active, users) for user in active_users: