Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techbrownbags/cbed4347356a8dafcf4fcb387b610a10 to your computer and use it in GitHub Desktop.
Save techbrownbags/cbed4347356a8dafcf4fcb387b610a10 to your computer and use it in GitHub Desktop.
@csrf_protect
def systems_search(request):
name = request.POST['name']
comments = request.POST['comments']
systems = System.objects.filter(name__icontains=name, comments__icontains=comments)[:10]
# systems = System.objects.all()[:5]
template = 'no_search_results.html'
context = None
if systems.count() > 0:
template = 'systems/_search.html'
context = {
"systems": systems
}
# https://docs.djangoproject.com/en/2.1/ref/template-response/
return render(request, template, context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment