From f7facf826df3f01cceaed754f9486a0e17d96581 Mon Sep 17 00:00:00 2001 From: Semyon Date: Fri, 18 Oct 2019 18:37:24 +0300 Subject: [PATCH] Implemented chosen tags by adding priority field: chosen tags should have non-null priority field, other tags should have null priority field. --- apps/tag/migrations/0003_tag_priority.py | 18 ++++++++++++++++++ apps/tag/models.py | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 apps/tag/migrations/0003_tag_priority.py diff --git a/apps/tag/migrations/0003_tag_priority.py b/apps/tag/migrations/0003_tag_priority.py new file mode 100644 index 00000000..5e93bcaa --- /dev/null +++ b/apps/tag/migrations/0003_tag_priority.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2019-10-18 15:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tag', '0002_auto_20191009_1408'), + ] + + operations = [ + migrations.AddField( + model_name='tag', + name='priority', + field=models.IntegerField(default=None, null=True, unique=True), + ), + ] diff --git a/apps/tag/models.py b/apps/tag/models.py index b811796c..0e5f9859 100644 --- a/apps/tag/models.py +++ b/apps/tag/models.py @@ -14,6 +14,8 @@ class Tag(TranslatedFieldsMixin, models.Model): category = models.ForeignKey('TagCategory', on_delete=models.PROTECT, null=True, related_name='tags', verbose_name=_('Category')) + # chosen tags should have non-null priority,other tags priority should be null + priority = models.IntegerField(unique=True, null=True, default=None) class Meta: """Meta class."""