From 215e1b6c6b1cfcc94756151769c1735ddba3662a Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Thu, 14 Jan 2016 15:14:33 +0100 Subject: [PATCH] Regarding #3729 python -Werror generates warnings informing that on_delete is a required keyword in Django 2.0 --- rest_framework/authtoken/models.py | 3 ++- tests/models.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rest_framework/authtoken/models.py b/rest_framework/authtoken/models.py index 2fef61e53..65dd99702 100644 --- a/rest_framework/authtoken/models.py +++ b/rest_framework/authtoken/models.py @@ -18,7 +18,8 @@ class Token(models.Model): The default authorization token model. """ key = models.CharField(max_length=40, primary_key=True) - user = models.OneToOneField(AUTH_USER_MODEL, related_name='auth_token') + user = models.OneToOneField(AUTH_USER_MODEL, related_name='auth_token', + on_delete=models.CASCADE) created = models.DateTimeField(auto_now_add=True) def save(self, *args, **kwargs): diff --git a/tests/models.py b/tests/models.py index c265182b7..8ec274d8b 100644 --- a/tests/models.py +++ b/tests/models.py @@ -49,7 +49,8 @@ class ForeignKeyTarget(RESTFrameworkModel): class ForeignKeySource(RESTFrameworkModel): name = models.CharField(max_length=100) target = models.ForeignKey(ForeignKeyTarget, related_name='sources', - help_text='Target', verbose_name='Target') + help_text='Target', verbose_name='Target', + on_delete=models.CASCADE) # Nullable ForeignKey @@ -57,7 +58,8 @@ class NullableForeignKeySource(RESTFrameworkModel): name = models.CharField(max_length=100) target = models.ForeignKey(ForeignKeyTarget, null=True, blank=True, related_name='nullable_sources', - verbose_name='Optional target object') + verbose_name='Optional target object', + on_delete=models.CASCADE) # OneToOne @@ -68,4 +70,4 @@ class OneToOneTarget(RESTFrameworkModel): class NullableOneToOneSource(RESTFrameworkModel): name = models.CharField(max_length=100) target = models.OneToOneField(OneToOneTarget, null=True, blank=True, - related_name='nullable_source') + related_name='nullable_source', on_delete=models.CASCADE)