Created
August 20, 2015 23:47
-
-
Save fandrefh/7be31088d08f19d3e627 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def get_pacientes(request): | |
if request.is_ajax(): | |
q = request.GET.get('term', '') | |
pacientes = Paciente.objects.filter(nome__icontains = q)[:20] | |
results = [] | |
for paciente in pacientes: | |
paciente_json = {} | |
paciente_json = paciente.nome | |
results.append(paciente_json) | |
data = json.dumps(results) | |
else: | |
data = 'fail' | |
mimetype = 'application/json' | |
return HttpResponse(data, mimetype) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment