Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @classmethod
- def social_media_type(cls, field_name: str, query_string: str, query_set: QuerySet) -> QuerySet:
- """Фильтр по типу социальной сети."""
- social_media_type_field = split_query(query_string)
- query_set = query_set.filter(
- Q(social_media__social_media_type=social_media_type_field)
- )
- return query_set
- @classmethod
- def social_media_type_link(cls, field_name: str, query_string: str, query_set: QuerySet) -> QuerySet:
- """Фильтр по ссылки социальной сети."""
- filter_link_field = split_query(query_string)
- query_set = query_set.filter(
- Q(
- Q(reduce(lambda x, y: x | y,
- [Q(**{'social_media__link': par}) for par in filter_link_field]
- ))
- )
- )
- return query_set
- FIELDS_FILTERS = [
- GenericApiView.get_filter(
- filter_name='social_media__link_field', field_name='link', filer_method=Filters.social_media_type_link
- ),
- GenericApiView.get_filter(
- filter_name='social_media__social_media_type_field', field_name='social_media_type',
- filer_method=Filters.social_media_type
- ),
- ........
Add Comment
Please, Sign In to add comment