Issue
I have this code which takes the name into the "nm" variable
{% extends "base.html" %}
{% block title %}Search Page{% endblock %}
{% block content %}
<form action="#" method="post">
<p>User or Group:</p>
<p><input type="text" name="nm"/></p>
<p><input type="submit" value="submit"/></p>
</form>
{% endblock %}
I want to put this variable into a different html file which will show different things. Can anyone suggest me the most efficient way to make this happen?
Solution
If you're using Django, send the nm
text field back to your view in views.py
, where you should access that variable (nm = request.POST.get("nm")
) and then send that via the context
variable in the render()
function to your other HTML file (return render(request, "your_other_file.html", {"nm": nm})
), where you can access the variable via interpolation ({{ nm }}
)
Answered By - Robo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.