Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 6b763b5

Browse files
committed
Use utils.get_user_model()
1 parent 620bc5e commit 6b763b5

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

rest_framework_jwt/authentication.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from rest_framework.authentication import (BaseAuthentication,
66
get_authorization_header)
77

8+
from rest_framework_jwt import utils
89
from rest_framework_jwt.settings import api_settings
910

1011

@@ -60,12 +61,8 @@ def authenticate_credentials(self, payload):
6061
"""
6162
Returns an active user that matches the payload's user id and email.
6263
"""
63-
try:
64-
from django.contrib.auth import get_user_model
65-
except ImportError: # Django < 1.5
66-
from django.contrib.auth.models import User
67-
else:
68-
User = get_user_model()
64+
User = utils.get_user_model()
65+
6966
try:
7067
user_id = jwt_get_user_id_from_payload(payload)
7168

rest_framework_jwt/compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import rest_framework
22
from distutils.version import StrictVersion
33

4+
45
if StrictVersion(rest_framework.VERSION) < StrictVersion('3.0.0'):
56
from rest_framework.serializers import Serializer
67
else:

rest_framework_jwt/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
def get_user_model():
88
try:
99
from django.contrib.auth import get_user_model
10-
except ImportError: # django < 1.5
10+
except ImportError: # Django < 1.5
1111
from django.contrib.auth.models import User
1212
else:
1313
User = get_user_model()

0 commit comments

Comments
 (0)