mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
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:
parent
a96ebd74b1
commit
192719eed0
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user