aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/authtoken/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/authtoken/models.py')
-rw-r--r--rest_framework/authtoken/models.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/rest_framework/authtoken/models.py b/rest_framework/authtoken/models.py
index 8eac2cc4..a1a9315f 100644
--- a/rest_framework/authtoken/models.py
+++ b/rest_framework/authtoken/models.py
@@ -1,8 +1,9 @@
import binascii
import os
-from hashlib import sha1
+
from django.conf import settings
from django.db import models
+from django.utils.encoding import python_2_unicode_compatible
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
@@ -12,6 +13,7 @@ from django.db import models
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
+@python_2_unicode_compatible
class Token(models.Model):
"""
The default authorization token model.
@@ -34,7 +36,7 @@ class Token(models.Model):
return super(Token, self).save(*args, **kwargs)
def generate_key(self):
- return binascii.hexlify(os.urandom(20))
+ return binascii.hexlify(os.urandom(20)).decode()
- def __unicode__(self):
+ def __str__(self):
return self.key