I try to get related objects by get title of the current objects and and filter the common words between two titles, I could able to make something but it is not accurete
I get the title and split it using .split()
and use Q
to filter by first and second word but this not accurate
.What I want to do
I want get results by get the common words between the current object title and result title
def get_queryset(self):
book_pk = self.kwargs['pk']
book = Video.objects.get(pk=book_pk)
lst = book.title
split = lst.split()
return Book.objects.filter(Q(title__icontains=split[0]) & Q(title__icontains=split[1]))