I am working with Python Django and I have this really simple form, consisting of a button and an input field. The problem is that the input field is for some reason cleared after I submit the form. So How can I prevent it from clearing?
This is my python file:
def index(request):
# print(f"its me {os.getcwd()}")
txt = request.GET.get("some_txt")
if (request.GET.get('mybtn')):
print(f"THIS IS THE TEXT VALUE: {txt}")
else:
print("Has not been clicked")
return render(request, "main/index.html")
This is the HTML file:
<form action="#" method="get">
{% csrf_token %}
<input type="text" name="some_txt">
<button type="submit" class="btn btn-primary" value="mybtn" name="mybtn">Submit</button>
</form>