From e68d57dba6f9193d75c48d218dd98c7592e776ee Mon Sep 17 00:00:00 2001 From: ashwinishinde Date: Thu, 14 May 2015 11:35:08 +0530 Subject: Subject: Search By Keyword Description: 1)solved problem in filter. --- static/website/templates/ajax-keyword-search.html | 49 +++++------------------ static/website/templates/filter.html | 4 +- website/views.py | 8 +++- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/static/website/templates/ajax-keyword-search.html b/static/website/templates/ajax-keyword-search.html index 6200d95..a8e98aa 100644 --- a/static/website/templates/ajax-keyword-search.html +++ b/static/website/templates/ajax-keyword-search.html @@ -8,7 +8,7 @@
- + @@ -17,45 +17,18 @@ {% for question in questions %} + + + {{ question.category|truncatechars:12 }} + + - - -
FOSS Question Question Date Views Answers
- - {{ question.category|truncatechars:12 }} - - - - - - - {{ question.title|truncatechars:40 }} - - diff --git a/static/website/templates/filter.html b/static/website/templates/filter.html index d0c57f0..f04f226 100644 --- a/static/website/templates/filter.html +++ b/static/website/templates/filter.html @@ -27,7 +27,7 @@ - + @@ -35,7 +35,7 @@ {% for question in questions %}
FOSS Question Question Date Views Answers
- + {{ question.category|truncatechars:12 }} diff --git a/website/views.py b/website/views.py index 516c7d4..603a4c7 100644 --- a/website/views.py +++ b/website/views.py @@ -21,7 +21,7 @@ from django.db.models import Count admins = ( - 9, 4376, 4915, 14595, 12329, 22467, 5518, 30705 + 9, 4376, 4915, 14595, 12329, 22467, 5518, 30705 ) categories = FossCategory.objects.order_by('name') @@ -497,10 +497,14 @@ def ajax_notification_remove(request): def ajax_keyword_search(request): if request.method == "POST": key = request.POST['key'] - questions = Question.objects.filter(title__icontains=key) + + questions = Question.objects.filter(title__contains=key) + context = { 'questions': questions } + + return render(request, 'website/templates/ajax-keyword-search.html', context) @csrf_exempt -- cgit