Previously, user_condition was assuming that the default
User model was being used. This causes an error in projects
using custom user models.
Instead of taking the hit of loading the user record from
the database again within the condition, we should be able
to just compare the provided username against the user
instance that is already attached to the request.
Both the AbstractBaseUser and AnonymousUser implement a
get_username() function so it should be safe to rely on
that.
Previously,
user_condition
was assuming that the default User model was being used. This causes an error in projects using custom user models.Instead of taking the hit of loading the user record from the database again within the condition, we should be able to just compare the provided username against the user instance that is already attached to the request.
Both the
AbstractBaseUser
andAnonymousUser
implement aget_username()
function so it should be safe to rely on that.