From 9e8ddb88fcc26e85202c37fc1b2aca80ef82c17a Mon Sep 17 00:00:00 2001 From: Xavier Ordoquy Date: Thu, 21 Jan 2016 13:28:32 +0100 Subject: [PATCH] Restore the abstract on Token model when the app isn't declared 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. --- rest_framework/authtoken/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rest_framework/authtoken/models.py b/rest_framework/authtoken/models.py index 65dd99702..b71dffa4a 100644 --- a/rest_framework/authtoken/models.py +++ b/rest_framework/authtoken/models.py @@ -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()