- return render_to_response('newuser.html', {'cform': form, 'sandwiches': sandwiches,})
\ No newline at end of file
+ return render_to_response('newuser.html', {'cform': form,}, context_instance=RequestContext(request))
+
+
+def ajaxfun(request):
+ if request.method == 'GET':
+ if 'q' in request.GET:
+ query = request.GET['q']
+ ingredients = Ingredient.objects.filter(name__icontains=query).order_by('name')
+ responselist = []
+ for i in ingredients:
+ responselist.append({'id': str(i.pk), 'name': i.name})
+ response = json.dumps(responselist)
+ return HttpResponse(response)
+ else:
+ return HttpResponse('{}')
\ No newline at end of file