15 lines
397 B
Python
15 lines
397 B
Python
from django.shortcuts import render
|
|
|
|
from content.models import Question
|
|
|
|
|
|
def search_question(request):
|
|
term = request.GET.get('term')
|
|
items = []
|
|
published = Question.objects.filter(is_published=True)
|
|
if term:
|
|
items = Question.get_by_tearchterm(term, published)
|
|
else:
|
|
items = published.all()[:10]
|
|
return render(request, 'questions.html', {'items': items})
|