0

i have a dropdown list having the store name,when i select a store from that i need store_key from that select value

def store_list(request):
     displaystores=stores.objects.all()
     if request.POST:
         store_pk_list = request.POST.getlist('stores', None)
         print(request.POST.getlist('stores.unit_key', None))

         selected_store_obj_list = stores.objects.filter(pk__in=store_pk_list)
         print(selected_store_obj_list)
        
    return render(request,'storelist.html',{'stores':displaystores})

html

 <form action="" method="post">
  {% csrf_token %}
--store_name--
 {%for result in stores%}
  <option value="{{result.unit_key}}">{{result.unit_name}}</option>
  {%endfor%}

</select>

1 Answer 1

0

Once you get the form through the POST, validate the data and then use them, Check this,

getting value from form field

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.