Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!