From 192719eed0ffc8ecd423b18e07bf52921dbfbcc2 Mon Sep 17 00:00:00 2001 From: Petros Moisiadis Date: Tue, 19 May 2015 20:00:19 +0300 Subject: [PATCH] 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. --- rest_framework/authentication.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index cf54d4563..8b5c20090 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -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