diff --git a/app/migrations/0046_alter_keyword_mother.py b/app/migrations/0046_alter_keyword_mother.py new file mode 100644 index 0000000..84ab1a8 --- /dev/null +++ b/app/migrations/0046_alter_keyword_mother.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.5 on 2021-11-29 01:58 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0045_auto_20211128_1636'), + ] + + operations = [ + migrations.AlterField( + model_name='keyword', + name='mother', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='mother_keyword', to='app.keyword'), + ), + ] diff --git a/app/models.py b/app/models.py index 349b54a..4468742 100644 --- a/app/models.py +++ b/app/models.py @@ -480,11 +480,12 @@ class ImportGeom210915(models.Model): class Keyword(models.Model): keyword_id = models.AutoField(primary_key=True) - mother = models.TextField(blank=True, null=True) + mother = models.ForeignKey("self", models.DO_NOTHING, blank=True, null=True, to_field='keyword_id', + related_name='mother_keyword') keyword = models.TextField(blank=True, null=True) def __str__(self): - return '%s - %s' % (self.keyword, self.mother) + return '%s > %s' % (self.mother, self.keyword) class ResourceKeyword(models.Model):