I found a couple of resources online, but none that worked for me. Here is what I currently have:
In views.py:
def button(request):
return render(request, 'home.html')
def display_text(request):
return HttpResponse('TESTING', status=200)
In urls.py:
urlpatterns = [
url(r'^$', views.button),
url(r'^display_text', views.display_text, name='script'),
]
In home.html:
<div class="row">
<input type="text" class="form-control js-text" id="input-box" placeholder="Type something to begin..."/>
<div class="col-md-12" style="text-align:center;">
<button onclick="location.href='{% url 'script' %}'"></button> <hr>
</div>
</div>
What happens right now is that it displays the string on a new web page. What I want to do is populate my text-box with that string returned by my Python function, and display it on the current page. How can I do so? Thanks!