From b5b39a5c18cfca576bd4f0cf7478ccef6a60c558 Mon Sep 17 00:00:00 2001 From: Dana Lambert Date: Fri, 5 Nov 2021 11:13:59 +1300 Subject: [PATCH] Alter the habitat image model to use a related name images --- .../0004_alter_habitatimage_habitat.py | 19 +++++++++++++++++++ backend/right_tree/api/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 backend/right_tree/api/migrations/0004_alter_habitatimage_habitat.py diff --git a/backend/right_tree/api/migrations/0004_alter_habitatimage_habitat.py b/backend/right_tree/api/migrations/0004_alter_habitatimage_habitat.py new file mode 100644 index 0000000..8bc2ba5 --- /dev/null +++ b/backend/right_tree/api/migrations/0004_alter_habitatimage_habitat.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.8 on 2021-11-04 04:52 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0003_plant_zones'), + ] + + operations = [ + migrations.AlterField( + model_name='habitatimage', + name='habitat', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='api.habitat'), + ), + ] diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index ea1bdda..4129cc0 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -61,7 +61,7 @@ class Habitat(models.Model): class HabitatImage(models.Model): habitat = models.ForeignKey( - Habitat, related_name='habitat', on_delete=models.CASCADE) + Habitat, related_name='images', on_delete=models.CASCADE) name = models.CharField(max_length=50) image_filename = models.CharField(max_length=50, default='-')