'i am passing none value

from django.shortcuts import render
from django.db.models import Q
from shop.models import Product


def search(request):
    products=None
    query=None

    if 'q' in request.GET:
        query = request.GET.get('q')

        products = Product.objects.all().filter(Q(name__contains=query) | Q(description__contains=query))

    return render(request,'search.html',{'query':query,'products':products})

this is my code i always get a none value for products and query



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source