Skip to content

Commit

Permalink
Restore the abstract on Token model when the app isn't declared
Browse files Browse the repository at this point in the history
The fact that we don't import Token from authentication doesn't invalidate
the need for the model to be abstract whenever the authtoken isn't listed
in the INSTALLED_APPS.
  • Loading branch information
xordoquy committed Jan 21, 2016
1 parent 06dd55a commit 9e8ddb8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rest_framework/authtoken/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class Token(models.Model):
on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)

class Meta:
# Work around for a bug in Django:
# https://code.djangoproject.com/ticket/19422
#
# Also see corresponding ticket:
# https://github.com/tomchristie/django-rest-framework/issues/705
abstract = 'rest_framework.authtoken' not in settings.INSTALLED_APPS

def save(self, *args, **kwargs):
if not self.key:
self.key = self.generate_key()
Expand Down

0 comments on commit 9e8ddb8

Please sign in to comment.