Add tags to Pumping model

This commit is contained in:
Brian O'Connor 2023-01-28 09:14:23 -05:00 committed by Christopher Charbonneau Wells
parent d1344a06c2
commit 945e30adb9
3 changed files with 28 additions and 2 deletions

View File

@ -138,10 +138,10 @@ class TaggableModelForm(forms.ModelForm):
) )
class PumpingForm(CoreModelForm): class PumpingForm(CoreModelForm, TaggableModelForm):
class Meta: class Meta:
model = models.Pumping model = models.Pumping
fields = ["child", "amount", "time", "notes"] fields = ["child", "amount", "time", "notes", "tags"]
widgets = { widgets = {
"child": ChildRadioSelect, "child": ChildRadioSelect,
"time": forms.DateTimeInput( "time": forms.DateTimeInput(

View File

@ -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",
),
),
]

View File

@ -428,6 +428,7 @@ class Pumping(models.Model):
amount = models.FloatField(blank=False, null=False, verbose_name=_("Amount")) amount = models.FloatField(blank=False, null=False, verbose_name=_("Amount"))
time = models.DateTimeField(blank=False, null=False, verbose_name=_("Time")) time = models.DateTimeField(blank=False, null=False, verbose_name=_("Time"))
notes = models.TextField(blank=True, null=True, verbose_name=_("Notes")) notes = models.TextField(blank=True, null=True, verbose_name=_("Notes"))
tags = TaggableManager(blank=True, through=Tagged)
objects = models.Manager() objects = models.Manager()