From 945e30adb985c0de760d9aac75ee29bf469f6077 Mon Sep 17 00:00:00 2001 From: Brian O'Connor Date: Sat, 28 Jan 2023 09:14:23 -0500 Subject: [PATCH] Add tags to Pumping model --- core/forms.py | 4 ++-- core/migrations/0025_pumping_tags.py | 25 +++++++++++++++++++++++++ core/models.py | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 core/migrations/0025_pumping_tags.py diff --git a/core/forms.py b/core/forms.py index 3fffaf2c..777e002c 100644 --- a/core/forms.py +++ b/core/forms.py @@ -138,10 +138,10 @@ class TaggableModelForm(forms.ModelForm): ) -class PumpingForm(CoreModelForm): +class PumpingForm(CoreModelForm, TaggableModelForm): class Meta: model = models.Pumping - fields = ["child", "amount", "time", "notes"] + fields = ["child", "amount", "time", "notes", "tags"] widgets = { "child": ChildRadioSelect, "time": forms.DateTimeInput( diff --git a/core/migrations/0025_pumping_tags.py b/core/migrations/0025_pumping_tags.py new file mode 100644 index 00000000..8e04dcf0 --- /dev/null +++ b/core/migrations/0025_pumping_tags.py @@ -0,0 +1,25 @@ +# Generated by Django 4.1.3 on 2023-01-28 13:59 + +import core.models +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0024_alter_tag_slug"), + ] + + operations = [ + migrations.AddField( + model_name="pumping", + name="tags", + field=core.models.TaggableManager( + blank=True, + help_text="A comma-separated list of tags.", + through="core.Tagged", + to="core.Tag", + verbose_name="Tags", + ), + ), + ] diff --git a/core/models.py b/core/models.py index 176a3427..22dc404f 100644 --- a/core/models.py +++ b/core/models.py @@ -428,6 +428,7 @@ class Pumping(models.Model): amount = models.FloatField(blank=False, null=False, verbose_name=_("Amount")) time = models.DateTimeField(blank=False, null=False, verbose_name=_("Time")) notes = models.TextField(blank=True, null=True, verbose_name=_("Notes")) + tags = TaggableManager(blank=True, through=Tagged) objects = models.Manager()