Merge pull request #3832 from atombrella/warnings_20_fkeys

Regarding #3729
This commit is contained in:
Xavier Ordoquy 2016-01-14 15:31:31 +01:00
commit b76bf3d6d2
2 changed files with 7 additions and 4 deletions

View File

@ -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):

View File

@ -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)