aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2015-02-04 14:20:21 +0000
committerTom Christie2015-02-04 14:20:21 +0000
commitd21617ff3bc39114a8d9cb75666158e80f1242d0 (patch)
tree15da031a9587fb2277b1361de8ca39f61b9d5424 /rest_framework
parent46181341d5579cb7a1b07cd7203b2f94b6c9c119 (diff)
parent58e7bbc8ecad8016cc18f7dbd31b235cb515b785 (diff)
downloaddjango-rest-framework-d21617ff3bc39114a8d9cb75666158e80f1242d0.tar.bz2
Merge pull request #2519 from Ofir-Purple/optimize-token-auth-queries
Prefetching the user object when getting the token in TokenAuthentication
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/authentication.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py
index 4832ad33..f7601fb1 100644
--- a/rest_framework/authentication.py
+++ b/rest_framework/authentication.py
@@ -167,7 +167,7 @@ class TokenAuthentication(BaseAuthentication):
def authenticate_credentials(self, key):
try:
- token = self.model.objects.get(key=key)
+ token = self.model.objects.select_related('user').get(key=key)
except self.model.DoesNotExist:
raise exceptions.AuthenticationFailed('Invalid token')