Created
April 4, 2019 16:53
-
-
Save techbrownbags/cbed4347356a8dafcf4fcb387b610a10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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