Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

337
Visualizações
How do you return result after entering text in form in django?

As an exercise I'd like to write a web app that returns keyword prediction after user enters content in the form. So, if a user enters some "text" in form, then below the form in, the keyword should appear.

I'm thinking that one approach could be using redirect to another view function that produces the prediction model function in view then the returned result would be a revised template. But, I'm not too sure about the following:

  1. Could multiple functions be placed in the view under the same url patterns?
  2. Is there an if condition that can be applied on the same template holding the form such that if the user submits, then the template shows results?

View:

def content_to_predict(request):
    if request.method == "POST":
        form = InputForm(request.POST)
        if form.is_valid():
            return redirect('show_prediction_result')
    else:
        form = InputForm()
    return render(request, 'prediction/content_input.html', {'form': form})

Template:

<h1> Input Content: </h1>
<form method="POST" class="post-form">{% csrf_token %}
    {{ form.as_p }}
    <button type="submit" class="save btn btn-default">Save</button>
</form>
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda