Sending additional info in post request

I am trying to implement a form with a "Contacts" datalist, I need to get the id number of the contact in order to process it in the db in Django but I don’t want the id to be shown to the user, I want the datalist to have the "normal" info. The datalist code is the following:

            <div class="form-group">
                <label class="form-label" for="contactOptions">Contact:</label>
                <input class="form-control" name="contact" list="contactOptions" placeholder="Type contact">
                <datalist id="contactOptions">
                    {% for contact in contact_options %}
                        <option>
                            {{contact.id}}: {{ contact.info }}
                        </option>
                    {% endfor %}
                </datalist>
            </div>

To sum up:

  • Want to populate the datalist with the info of the contacts except the id.
  • Need to get the contact id when using request.post in the views in Django.
  • I have a JS file to manipulate the HTML if required.

76 thoughts on “Sending additional info in post request”

Leave a Comment