From 9d3c32fec1e8107e1f6c7ece8b26fac6a6f7ae67 Mon Sep 17 00:00:00 2001 From: Marcelino Alberdi Pereira Date: Mon, 13 Jun 2022 04:07:19 +0200 Subject: [PATCH] Fix filtering not working for capitalized tags (#480) Closes #467. --- babybuddy/management/commands/fake.py | 5 +++-- core/filters.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/babybuddy/management/commands/fake.py b/babybuddy/management/commands/fake.py index 1cddd5ac..288a04ae 100644 --- a/babybuddy/management/commands/fake.py +++ b/babybuddy/management/commands/fake.py @@ -44,9 +44,10 @@ class Command(BaseCommand): children = int(kwargs["children"]) or 1 days = int(kwargs["days"]) or 31 - for word in self.faker.words(10, unique=True): + for i in range(0, 10): + text = self.faker.password(randint(4, 10)) try: - tag = models.Tag.objects.create(name=word) + tag = models.Tag.objects.create(name=text) tag.save() self.tags.append(tag) except IntegrityError: diff --git a/core/filters.py b/core/filters.py index 1d5dc36c..a2358c93 100644 --- a/core/filters.py +++ b/core/filters.py @@ -9,8 +9,7 @@ from core import models class TagFilter(django_filters.FilterSet): tag = django_filters.ModelChoiceFilter( label=_("Tag"), - field_name="tags__slug", - to_field_name="slug", + field_name="tags__name", distinct=True, queryset=models.Tag.objects.all().order_by("name"), )