I'm building a multi-language Django site and using 'Django-parler' for my model data translations. Now I'm wondering if there is a Django search app that works with multi-language models and I used to create the search functionality here, it works fine for single-language sites. But, I can't get it to work with multiple language filter functions.
Here is my models.py
from django.db import models
from parler.models import TranslatableModel, TranslatedFields
class Category (TranslatableModel):
translations = TranslatedFields(
category_Title=models.CharField(max_length=500)
)
def __str__(self):
return self.category_Title
class Faq_QA(TranslatableModel):
translations = TranslatedFields(
question_Title=models.CharField(max_length=500),
question_Description=models.TextField(),
category_Option=models.ForeignKey(Category, on_delete=models.CASCADE),
SEO_Keywords=models.TextField(),
)
def __str__(self):
return self.question_Title
Here is my search View.py
from django.shortcuts import render
from .models import Category, Faq_QA
from django.db.models import Q
# Create your views here.
def base(request):
if 'q' in request.GET:
q = request.GET['q']
multiple_keywords_faq = Q(Q(question_Title__icontains=q) | Q(question_Description__icontains=q))
search_key_faq = Faq_QA.objects.filter(multiple_keywords_faq)
else:
search_key_faq = Faq_QA.objects.all()
context = {
'search_data': search_key_faq,
'category_data': Category.objects.all(),
}
return render(request, 'Base.html', context)
For references my error-throwing image is here;
Can anyone please help me with this error,
Top comments (0)