##// END OF EJS Templates
Search posts by text and title
neko259 -
r1849:d9dcb07b default
parent child Browse files
Show More
@@ -1,5 +1,6 b''
1 from django.shortcuts import render
1 from django.shortcuts import render
2 from django.views.generic import View
2 from django.views.generic import View
3 from django.db.models import Q
3
4
4 from boards.abstracts.paginator import get_paginator
5 from boards.abstracts.paginator import get_paginator
5 from boards.forms import SearchForm, PlainErrorList
6 from boards.forms import SearchForm, PlainErrorList
@@ -32,8 +33,8 b' class BoardSearchView(View):'
32 if form.is_valid():
33 if form.is_valid():
33 query = form.cleaned_data[FORM_QUERY]
34 query = form.cleaned_data[FORM_QUERY]
34 if len(query) >= MIN_QUERY_LENGTH:
35 if len(query) >= MIN_QUERY_LENGTH:
35 results = Post.objects.filter(text__icontains=query)\
36 results = Post.objects.filter(Q(text__icontains=query) |
36 .order_by('-id')
37 Q(title__icontains=query)).order_by('-id')
37 paginator = get_paginator(results, RESULTS_PER_PAGE)
38 paginator = get_paginator(results, RESULTS_PER_PAGE)
38
39
39 page = int(request.GET.get(REQUEST_PAGE, '1'))
40 page = int(request.GET.get(REQUEST_PAGE, '1'))
General Comments 0
You need to be logged in to leave comments. Login now