Skip to content

Instantly share code, notes, and snippets.

@jlaya
Created April 15, 2019 19:27
Show Gist options
  • Save jlaya/25f21c80bb3578702f73ec85a72ae900 to your computer and use it in GitHub Desktop.
Save jlaya/25f21c80bb3578702f73ec85a72ae900 to your computer and use it in GitHub Desktop.
Views.py
def product_autocomplete(request):
q = request.GET.get('name')
if q:
obj = Product.objects.filter(model_reference__startswith=q)
leads_as_json = serializers.serialize('json', obj)
return HttpResponse(leads_as_json, content_type='json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment