Skip to content

Commit 192719e

Browse files
committed
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.
1 parent a96ebd7 commit 192719e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

rest_framework/authentication.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ def authenticate_credentials(self, userid, password):
8686
"""
8787
Authenticate the userid and password against username and password.
8888
"""
89-
user_model = get_user_model()
90-
if hasattr(user_model, 'USERNAME_FIELD'):
91-
username_field = user_model.USERNAME_FIELD
92-
else:
93-
username_field = 'username'
89+
username_field = getattr(get_user_model(), 'USERNAME_FIELD', 'username')
9490
credentials = {
9591
username_field: userid,
9692
'password': password

0 commit comments

Comments
 (0)