javascript - Send only specific value to server in Django -
i have html code this:
{% i, j, k in full_name %} {{ }} {{ j }} <input type="text" name="follow_id" value="{{ k }}" /> <input type="submit" value="follow"><br /> <br /> {% endfor %}
the output looks this:
user1 user_id_of_user1 follow_button user2 user_id_of_user2 follow_button user3 user_id_of_user3 follow_button
if press follow button of user3 want send id of user3 can access in server this:
followed_user = request.post['follow_id'] # process
but, no matter follow_button press, user id of user1. how fix this?
this not django issue, html issue. here work around: 1 form each user:
{% i, j, k in full_name %} <form action="mydomain.com/mysubmiturl/" method="post"><!-- leave action empty submit same html --> {% csrf_token %} <!-- django server accept post requests csrf token --> {{ }} {{ j }} <input type="text" name="follow_id" value="{{ k }}" /> <input type="submit" value="follow"><br /> <br /> </form> {% endfor %}
note forms submit same url, , same view function !
Comments
Post a Comment