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. Authenticate the userid and password against username and password.
""" """
user_model = get_user_model() username_field = getattr(get_user_model(), 'USERNAME_FIELD', 'username')
if hasattr(user_model, 'USERNAME_FIELD'):
username_field = user_model.USERNAME_FIELD
else:
username_field = 'username'
credentials = { credentials = {
username_field: userid, username_field: userid,
'password': password 'password': password