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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -