mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-27 01:34:31 +03:00
Merge pull request #3832 from atombrella/warnings_20_fkeys
Regarding #3729
This commit is contained in:
commit
b76bf3d6d2
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user