Attempt a fix for self relationship of Keyword
This commit is contained in:
parent
a8e2ee2c94
commit
7f2c9693a6
2 changed files with 22 additions and 2 deletions
19
app/migrations/0046_alter_keyword_mother.py
Normal file
19
app/migrations/0046_alter_keyword_mother.py
Normal file
|
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -480,11 +480,12 @@ class ImportGeom210915(models.Model):
|
||||||
|
|
||||||
class Keyword(models.Model):
|
class Keyword(models.Model):
|
||||||
keyword_id = models.AutoField(primary_key=True)
|
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)
|
keyword = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s - %s' % (self.keyword, self.mother)
|
return '%s > %s' % (self.mother, self.keyword)
|
||||||
|
|
||||||
|
|
||||||
class ResourceKeyword(models.Model):
|
class ResourceKeyword(models.Model):
|
||||||
|
|
Loading…
Add table
Reference in a new issue