From 993990a7cbe0dd573421d1fc261b2ca019a49aa1 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 26 Nov 2021 13:00:23 +0530 Subject: [PATCH] Attempt to link Range and RangeType models --- app/migrations/0023_alter_range_feature.py | 19 +++++++++++++++++++ app/models.py | 18 +++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 app/migrations/0023_alter_range_feature.py diff --git a/app/migrations/0023_alter_range_feature.py b/app/migrations/0023_alter_range_feature.py new file mode 100644 index 0000000..220ccbc --- /dev/null +++ b/app/migrations/0023_alter_range_feature.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.5 on 2021-11-26 07:28 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0022_alter_organization_country'), + ] + + operations = [ + migrations.AlterField( + model_name='range', + name='feature', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='app.rangetype'), + ), + ] diff --git a/app/models.py b/app/models.py index 02032d3..600289f 100644 --- a/app/models.py +++ b/app/models.py @@ -68,6 +68,14 @@ class Language(models.Model): return self.language +class RangeType(models.Model): + id = models.AutoField(primary_key=True) + range_type = models.TextField(blank=True, null=True) + + def __str__(self): + return self.range_type + + class Range(models.Model): id = models.AutoField(primary_key=True) source_id = models.IntegerField(blank=True, null=True) @@ -80,7 +88,7 @@ class Range(models.Model): range_name_ascii = models.TextField(blank=True, null=True) range_name_language = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True, to_field='id') mother_range = models.ForeignKey("self", models.DO_NOTHING, blank=True, null=True, to_field='id') - feature = models.TextField(blank=True, null=True) # TODO needs to be a drop down + feature = models.ForeignKey(RangeType, models.DO_NOTHING, blank=True, null=True, to_field='id') map_unit = models.TextField(blank=True, null=True) level = models.TextField(blank=True, null=True) level_text = models.TextField(blank=True, null=True) @@ -237,14 +245,6 @@ class PeopleStatus(models.Model): return self.status -class RangeType(models.Model): - id = models.AutoField(primary_key=True) - range_type = models.TextField(blank=True, null=True) - - def __str__(self): - return self.range_type - - class RedListCategory(models.Model): id = models.AutoField(primary_key=True) red_list_category = models.TextField(blank=True, null=True)