aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tokenauth/models.py
diff options
context:
space:
mode:
authorAlec Perkins2012-09-09 13:23:07 -0400
committerAlec Perkins2012-09-09 13:23:07 -0400
commit45001033378a49986d4cd7f5bdf4673b083cdbd0 (patch)
treee5eb2cd49d122ba56d63058413cb3d4d138dae7a /djangorestframework/tokenauth/models.py
parent0ae5500f34a81005ba0161dacb280a94f768a885 (diff)
parentd4f8b4cf0683923fe85652f8fd572d2931eb3074 (diff)
downloaddjango-rest-framework-45001033378a49986d4cd7f5bdf4673b083cdbd0.tar.bz2
Merge 'tomchristie/restframework2' into 'browsable-bootstrap'
Diffstat (limited to 'djangorestframework/tokenauth/models.py')
-rw-r--r--djangorestframework/tokenauth/models.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/djangorestframework/tokenauth/models.py b/djangorestframework/tokenauth/models.py
new file mode 100644
index 00000000..f289b0fd
--- /dev/null
+++ b/djangorestframework/tokenauth/models.py
@@ -0,0 +1,15 @@
+import uuid
+from django.db import models
+
+class BasicToken(models.Model):
+ """
+ The default authorization token model class.
+ """
+ key = models.CharField(max_length=32, primary_key=True, blank=True)
+ user = models.ForeignKey('auth.User')
+ revoked = models.BooleanField(default=False)
+
+ def save(self, *args, **kwargs):
+ if not self.key:
+ self.key = uuid.uuid4().hex
+ return super(BasicToken, self).save(*args, **kwargs)