Add zones to plant model
This commit is contained in:
parent
34561a85bb
commit
d48f202634
2 changed files with 44 additions and 26 deletions
18
backend/right_tree/api/migrations/0003_plant_zones.py
Normal file
18
backend/right_tree/api/migrations/0003_plant_zones.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.8 on 2021-11-04 00:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0002_habitat_habitatimage_zone_zoneimagesegment'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='plant',
|
||||
name='zones',
|
||||
field=models.ManyToManyField(to='api.Zone'),
|
||||
),
|
||||
]
|
|
@ -52,32 +52,6 @@ class ToleranceLevel(models.Model):
|
|||
def __str__(self):
|
||||
return self.level
|
||||
|
||||
|
||||
class Plant(models.Model):
|
||||
name = models.CharField(unique=True, max_length=50)
|
||||
commonname = models.CharField(null=True, blank=True, max_length=200)
|
||||
maxheight = models.FloatField()
|
||||
spacing = models.FloatField()
|
||||
synonym = models.CharField(null=True, blank=True, max_length=200)
|
||||
water_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='water_tolerance', on_delete=models.CASCADE)
|
||||
drought_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='drought_tolerance', on_delete=models.CASCADE)
|
||||
frost_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='frost_tolerance', on_delete=models.CASCADE)
|
||||
salinity_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='salinity_tolerance', on_delete=models.CASCADE)
|
||||
purpose = models.TextField(null=True, blank=True)
|
||||
stage = models.PositiveIntegerField()
|
||||
growth_form = models.CharField(null=True, blank=True, max_length=50)
|
||||
ecological_regions = models.ManyToManyField(EcologicalRegion)
|
||||
soil_order = models.ManyToManyField(SoilOrder)
|
||||
soil_variants = models.ManyToManyField(SoilVariant)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Habitat(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
|
@ -118,3 +92,29 @@ class ZoneImageSegment(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return f"{self.habitat_image.name}, {self.zone.name}"
|
||||
|
||||
|
||||
class Plant(models.Model):
|
||||
name = models.CharField(unique=True, max_length=50)
|
||||
commonname = models.CharField(null=True, blank=True, max_length=200)
|
||||
maxheight = models.FloatField()
|
||||
spacing = models.FloatField()
|
||||
synonym = models.CharField(null=True, blank=True, max_length=200)
|
||||
water_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='water_tolerance', on_delete=models.CASCADE)
|
||||
drought_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='drought_tolerance', on_delete=models.CASCADE)
|
||||
frost_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='frost_tolerance', on_delete=models.CASCADE)
|
||||
salinity_tolerance = models.ForeignKey(
|
||||
ToleranceLevel, related_name='salinity_tolerance', on_delete=models.CASCADE)
|
||||
purpose = models.TextField(null=True, blank=True)
|
||||
stage = models.PositiveIntegerField()
|
||||
growth_form = models.CharField(null=True, blank=True, max_length=50)
|
||||
ecological_regions = models.ManyToManyField(EcologicalRegion)
|
||||
soil_order = models.ManyToManyField(SoilOrder)
|
||||
soil_variants = models.ManyToManyField(SoilVariant)
|
||||
zones = models.ManyToManyField(Zone)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
Loading…
Reference in a new issue