I want to use filter with OR condition in django. For this i want to use Q objects. My code is this
def product(request):
try:
proTitle = request.GET.get('title')
ProDescription = request.GET.get('description')
except:
pass
list0 = []
result = Product.objects.filter(Q(title__contains=proTitle ) | Q(description__contains=ProDescription ) )
for res in result:
list0.append(res.project_id)
data ={'title result':list0}
return HttpResponse(json.dumps(data))
return HttpResponse(json.dumps(data), content_type='application/json')
When pass all value that is proTitle,ProDescription
it working fine.
If any value is going to none it encounter a error
Cannot use None as a query value`
Why this error occured when i am using OR operator into my queryset
I am also try this
result = Project.objects.filter(title__contains=proTitle) | Project.objects.filter(description__contains=ProDescription )
but same error occured I am unable to understand actually what is the problem