X-Git-Url: https://code.kerkeslager.com/?p=climbing.kerkeslager.com;a=blobdiff_plain;f=src%2Fclimbing%2Fmodels.py;fp=src%2Fclimbing%2Fmodels.py;h=1693a0592ce6b8ce74efe20602f82cba7e5cfbd5;hp=0f17d7a4f305ab3fd54a3065c38152722a57b235;hb=34cb29afd3a9270e0b3e11d74c465af3aa1c49ce;hpb=80001e429bdc7f15c15d969eb4c5e1ca1bca7345 diff --git a/src/climbing/models.py b/src/climbing/models.py index 0f17d7a..1693a05 100644 --- a/src/climbing/models.py +++ b/src/climbing/models.py @@ -5,12 +5,20 @@ class Area(models.Model): notes = models.TextField() class Crag(models.Model): - area = models.ForeignKey(Area, on_delete=models.CASCADE) + area = models.ForeignKey( + Area, + on_delete=models.CASCADE, + related_name='crags', + ) name = models.CharField(max_length=64) notes = models.TextField() class Route(models.Model): - area = models.ForeignKey(Crag, on_delete=models.CASCADE) + area = models.ForeignKey( + Crag, + on_delete=models.CASCADE, + related_name='routes', + ) name = models.CharField(max_length=64) notes = models.TextField() @@ -65,19 +73,31 @@ SAFETY_CHOICES = ( ) class Pitch(models.Model): - route = models.ForeignKey(Route, on_delete=models.CASCADE) + route = models.ForeignKey( + Route, + on_delete=models.CASCADE, + related_name='pitches', + ) name = models.CharField(max_length=64, null=True) difficulty = models.CharField(max_length=5, choices=ROUTE_DIFFICULTY_CHOICES) safety = models.CharField(max_length=4, choices=SAFETY_CHOICES) notes = models.TextField() class Cluster(models.Model): - area = models.ForeignKey(Area, on_delete=models.CASCADE) + area = models.ForeignKey( + Area, + on_delete=models.CASCADE, + related_name='clusters', + ) name = models.CharField(max_length=64) notes = models.TextField() class Boulder(models.Model): - cluster = models.ForeignKey(Cluster, on_delete=models.CASCADE) + cluster = models.ForeignKey( + Cluster, + on_delete=models.CASCADE, + related_name='boulders', + ) name = models.CharField(max_length=64) notes = models.TextField() @@ -103,7 +123,11 @@ BOULDER_DIFFICULTY_CHOICES = ( ) class Problem(models.Model): - boulder = models.ForeignKey(Boulder, on_delete=models.CASCADE) + boulder = models.ForeignKey( + Boulder, + on_delete=models.CASCADE, + related_name='problems', + ) name = models.CharField(max_length=64) difficulty = models.CharField(max_length=3, choices=BOULDER_DIFFICULTY_CHOICES) safety = models.CharField(max_length=4, choices=SAFETY_CHOICES)