Improve coding style

On Tom's suggestion, improve coding style by using a single-line call to getattr() with a default value instead of a multi-line if/else clause.
This commit is contained in:
Petros Moisiadis 2015-05-19 20:00:19 +03:00
parent a96ebd74b1
commit 192719eed0

View File

@ -86,11 +86,7 @@ class BasicAuthentication(BaseAuthentication):
"""
Authenticate the userid and password against username and password.
"""
user_model = get_user_model()
if hasattr(user_model, 'USERNAME_FIELD'):
username_field = user_model.USERNAME_FIELD
else:
username_field = 'username'
username_field = getattr(get_user_model(), 'USERNAME_FIELD', 'username')
credentials = {
username_field: userid,
'password': password