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:
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>