0

I want to send the l.id value in the action which I will match in urlconf.

<form name="move_form" action="{% url index %}move_review/" method="post">
<select name="to_lst">

{% if list1 %}
{% for l in list1 %}
    <OPTION value={{ l.id }}>{{l.name }}-{{ l.age }}</OPTION>
{% endfor %}
{% else %}
<OPTION> None </OPTION>
{% endif %}
</select>

<INPUT type="submit" value="Accept" ><INPUT type="Reset">

What I want is to make the url like <mainip>/move_review/{l.id}/

Any help will be highly appreciated. Thanks.

Yevhen
  • 1,048
  • 1
  • 14
  • 24
Supratik
  • 1
  • 4

1 Answers1

0

try this

def your_function(request):
  id = request.POST.get("to_lst",None)
  #Do something 
  return render(request,"your_template.html")

In this case you need not pass id in urls.let form take care of it

  • Thanks for the solution. But suppose, in the context dictionary i am sending a key value pair which i am not using in the template. but i want that key value pair to be available for the next view which gets invoked from the form action. what do i want to do in that case? – Supratik Mar 07 '19 at 11:49
  • Got it. Done. Thanks for the support. – Supratik Mar 07 '19 at 12:07