How do I pass information from an HTML form into my Python code without specifying a URL mapping? For example, the following code sends the data from the form to my index.html template, to the myview mapping, which then calls the myview view function, which finally displays the mypage template ...
index.html
<form method="get" action="{% url 'myview' %}">
urls.py
urlpatterns = patterns('',
url(r'^mypage/$', views.myview, name='myview'),
)
views.py
def myview(request):
return render(request, 'myapp/mypage.html')
However, do I really need to have a url for this? What if I don’t want to reload another web page and I just want to stay on the same “index.html” page?
, , , , , , .
!