schon/engine/blog/filters.py
Egor fureunoir Gorbunov a81f734e23 Features: (1) None;
Fixes: (1) Removed all `# type: ignore` annotations across the codebase; (2) Fixed usage of Django Model methods by eliminating unnecessary `# type: ignore` directives; (3) Adjusted usage of functions like `get()` to align with method expectations, removing incorrect comments;

Extra: (1) Deleted `pyrightconfig.json` as part of migration to a stricter type-checked environment; (2) Minor code cleanup, including formatting changes and refactoring import statements in adherence to PEP8 recommendations.
2025-12-18 15:55:43 +03:00

26 lines
849 B
Python

from django_filters import CharFilter, FilterSet, OrderingFilter, UUIDFilter
from engine.blog.models import Post
from engine.core.filters import CaseInsensitiveListFilter
class PostFilter(FilterSet):
uuid = UUIDFilter(field_name="uuid", lookup_expr="exact")
slug = CharFilter(field_name="slug", lookup_expr="exact")
author = UUIDFilter(field_name="author__uuid", lookup_expr="exact")
tags = CaseInsensitiveListFilter(field_name="tags__tag_name", label="Tags")
order_by = OrderingFilter(
fields=(
("uuid", "uuid"),
("slug", "slug"),
("author__uuid", "author"),
("created", "created"),
("modified", "modified"),
("?", "random"),
)
)
class Meta:
model = Post
fields = ["uuid", "slug", "author", "tags", "order_by"]