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()