Hi, i want add search bar to myproject but don't return anything

this view for search:

class Search(generic.ListView):
    model = Blog
    template_name = 'pages/blog_list_view.html'
    context_object_name = 'blog'

    def get_queryset(self):
        search = self.request.GET.get("q")
        search_result = Blog.objects.filter(
            Q(title__icontains=search) |
            Q(description__icontains=search) |

        return search_result

search form in _base.html

<form action="{% url 'search' %}" method="get">
    <input name="q" type="text" placeholder="Search...">

my model

class Blog(models.Model):
    title = models.CharField(max_length=100)
    cover = models.ImageField(upload_to='blog_cover/')
    description = models.CharField(max_length=200)
    text = models.TextField()
    author = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
    active = models.BooleanField(default=False)

    date_create = models.DateField(auto_now_add=True)
    date_modified = models.DateField(auto_now=True)

    def __str__(self):
        return f'{self.title} : {self.author}'

    def get_absolute_url(self):
        return reverse('blog_detail', args=[self.id])

tip: "I use Persian language for search"

I tried __icontains and __contains but result was same

Back to Top