diff options
| author | Tom Christie | 2012-10-09 09:57:31 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-09 09:57:31 +0100 |
| commit | 5c17a60176d91b8ef8fa729096fd57481de7a4ea (patch) | |
| tree | 8eec620a04362380dcf2b93aa083ad1d46db6ad8 /rest_framework/authtoken/models.py | |
| parent | beea6487b214a0e40e0688a511cce5e065568632 (diff) | |
| download | django-rest-framework-5c17a60176d91b8ef8fa729096fd57481de7a4ea.tar.bz2 | |
Tweak authtoken
Diffstat (limited to 'rest_framework/authtoken/models.py')
| -rw-r--r-- | rest_framework/authtoken/models.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/rest_framework/authtoken/models.py b/rest_framework/authtoken/models.py index fd47e6c7..f7e78ef3 100644 --- a/rest_framework/authtoken/models.py +++ b/rest_framework/authtoken/models.py @@ -9,8 +9,7 @@ class Token(models.Model): The default authorization token model. """ key = models.CharField(max_length=40, primary_key=True) - user = models.ForeignKey('auth.User') - revoked = models.BooleanField(default=False) + user = models.OneToOneField('auth.User', related_name='api_key') created = models.DateTimeField(auto_now_add=True) def save(self, *args, **kwargs): @@ -21,3 +20,6 @@ class Token(models.Model): def generate_key(self): unique = str(uuid.uuid4()) return hmac.new(unique, digestmod=sha1).hexdigest() + + def __unicode__(self): + return self.key |
