-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ajax search feature added #82
base: master
Are you sure you want to change the base?
Conversation
This pull request introduces 1 alert when merging 9a0fd1d into 324a9f1 - view on LGTM.com new alerts:
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.devbridge-autocomplete/1.4.10/jquery.autocomplete.min.js"></script> | ||
<script> | ||
$('#search-bar').autocomplete({ | ||
serviceUrl: '/autocomplete' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use url
template tag?
def autocomplete(request): | ||
query = request.GET.get('query') | ||
tags = Tag.objects.filter(name__icontains=query) | ||
taglist = [] | ||
for t in tags: | ||
taglist.append(t.name) | ||
taglist_json = {"suggestions":taglist} | ||
taglist_string = json.dumps(taglist_json) | ||
return HttpResponse(taglist_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using json
module, you could also have used Django's JsonResponse
to send back a JSON object for autocomplete.
There is also the issue of you sending a PR from your master branch. Please see CONTRIBUTING.md. |
Ajax search feature added to home page so that users will be able to know what can be searched.