- I want to have a template with a text input and a submit button
- When I press submit I want to process that text with a python function
- Finally, when the function process the text I want to redirect to another page
This is my code, there’s too many stuff going on for me because i’m new, can you tell me if it’s right?
input_text.html:
<form action="{% url 'app.process_text' %}" method="post">
{% csrf_token %}
<input type="text">
<input type="submit" value="Submit">
</form>
urls.py:
from django.urls import path
from . import views
from .views import ProcessText
urlpatterns = [
...
path('projects/process_text', views.ProcessText, name='app_process_text'),
...
]
views.py:
def ProcessText(request):
# here im suposed to have a variable with the input to work with
return render(request, 'app/just_another_page.html')
Thanks in advance!