On Fri, Jan 2, 2009 at 7:48 AM, Praveen <praveen.python.pl...@gmail.com> wrote: > > <form action="." method="GET"> > > <label for="q">By product name : </label> > <input type="text" name="q" value="{{ query|escape }}"> > <label for="p">By date approval : </label> > <input type="text" name="p" value="{{ query1|escape }}"> > <input type="submit" value="Search"> > </form> > > views.py > import Q > > def proreport(request): > query = request.GET.get('q', '') > query1 = request.GET.get('p', '') > print query > print query1 > if query and query1 : > qset = ( > Q(product_name__startswith=query) & > Q(date_approval__icontains=query1) > ) > results = Products.objects.filter(qset).distinct() > else: > results = [] > return render_to_response("admin/report/product_report.html", > { "results": results, "query": query, "query1": query1}) > > database > in table date_approval field is saving in the format of (yyyy-mm-dd) > > error > > when i am giving the value 2008-10-10 in text box of p > > Caught an exception while rendering: Incorrect date value: > '%2008-10-10%' for column 'date_approval'
You only can search for text inside text. Here django tries to make text-pattern-matching on a date type. The code should be something as qset = ( Q(product_name__startswith=query) & Q(date_approval=query1) ) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---