I am using two views in django: one for showing a form and get data and then use the data as an argument to the second view. But I could not quite figure this out as how to do it.
So far my views look like
class View1(View):
def get(self, request):
return render(request, 'example/view1.html')
class View2(View):
def get(self, request, arg1):
token = processData(arg1)
context = {
'word': token,
}
return render(request, 'example/view2.html', context)
I have my urls.py set up as
app_name = example
urlpatterns = [
path('', View1.as_view(), name='view1'),
path('view2/', View2.as_view(), name='view2'),
]
Now in the template view1.html I have the following code
<form action="{% url 'example:view2 expected_argument %}" method="get">
{% csrf_token %}
<input id="key" type="text" name="key">
<input type="submit" value="Submit">
</form>
what would be the 'expected_argument' in the template so that I can get the input form value from the view1.html template, and then pass it on to the View2.