Fix filtering not working for capitalized tags (#480)

Closes #467.
This commit is contained in:
Marcelino Alberdi Pereira 2022-06-13 04:07:19 +02:00 committed by GitHub
parent b2c228fac9
commit 9d3c32fec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -44,9 +44,10 @@ class Command(BaseCommand):
children = int(kwargs["children"]) or 1 children = int(kwargs["children"]) or 1
days = int(kwargs["days"]) or 31 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: try:
tag = models.Tag.objects.create(name=word) tag = models.Tag.objects.create(name=text)
tag.save() tag.save()
self.tags.append(tag) self.tags.append(tag)
except IntegrityError: except IntegrityError:

View File

@ -9,8 +9,7 @@ from core import models
class TagFilter(django_filters.FilterSet): class TagFilter(django_filters.FilterSet):
tag = django_filters.ModelChoiceFilter( tag = django_filters.ModelChoiceFilter(
label=_("Tag"), label=_("Tag"),
field_name="tags__slug", field_name="tags__name",
to_field_name="slug",
distinct=True, distinct=True,
queryset=models.Tag.objects.all().order_by("name"), queryset=models.Tag.objects.all().order_by("name"),
) )