@@ -39,7 +39,7 @@ In order to explain the various types of relational fields, we'll use a couple o
...
@@ -39,7 +39,7 @@ In order to explain the various types of relational fields, we'll use a couple o
artist = models.CharField(max_length=100)
artist = models.CharField(max_length=100)
class Track(models.Model):
class Track(models.Model):
album = models.ForeignKey(Album, related_name='tracks')
album = models.ForeignKey(Album, related_name='tracks', on_delete=models.CASCADE)
order = models.IntegerField()
order = models.IntegerField()
title = models.CharField(max_length=100)
title = models.CharField(max_length=100)
duration = models.IntegerField()
duration = models.IntegerField()
...
@@ -484,7 +484,7 @@ Note that reverse relationships are not automatically included by the `ModelSeri
...
@@ -484,7 +484,7 @@ Note that reverse relationships are not automatically included by the `ModelSeri
You'll normally want to ensure that you've set an appropriate `related_name` argument on the relationship, that you can use as the field name. For example:
You'll normally want to ensure that you've set an appropriate `related_name` argument on the relationship, that you can use as the field name. For example:
class Track(models.Model):
class Track(models.Model):
album = models.ForeignKey(Album, related_name='tracks')
album = models.ForeignKey(Album, related_name='tracks', on_delete=models.CASCADE)
...
...
If you have not set a related name for the reverse relationship, you'll need to use the automatically generated related name in the `fields` argument. For example:
If you have not set a related name for the reverse relationship, you'll need to use the automatically generated related name in the `fields` argument. For example:
...
@@ -508,7 +508,7 @@ For example, given the following model for a tag, which has a generic relationsh
...
@@ -508,7 +508,7 @@ For example, given the following model for a tag, which has a generic relationsh