Created
March 14, 2016 17:26
-
-
Save andrelramos/0b5a28ee0462054d5a98 to your computer and use it in GitHub Desktop.
Exemplo de pesquisa AJAX (Controller)
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
| @login_requerido(['administrador', 'auxiliar'], '/') | |
| def consulta_cadastros(request): | |
| form = forms.PesquisaCadastrosForm() | |
| resposta = {} | |
| if request.method == "POST": | |
| form = forms.PesquisaCadastrosForm(request.POST) | |
| if form.is_valid: | |
| candidato = getCandidatoUsuario(request.user) | |
| argumentos = functions.argumentosPesquisa(request) | |
| resultado_pesquisa = models.Cadastro.objects.filter(candidato=candidato, **argumentos) | |
| pesquisa_json = serializers.serialize('json', resultado_pesquisa, use_natural_foreign_keys=True) | |
| return HttpResponse(pesquisa_json) | |
| resposta['form'] = form | |
| return render(request, 'consultas/cadastros.html', resposta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment