Multiple widgets for one form field in Django

I have the following form:

    class ExcipientForm(ModelForm):
    class Meta:
        model = Excipient
        fields = (
        widgets = {
            'Excipient_type': Select(attrs={
                'style' : 'width:100%;',
                'class' : 'dropdowns',
            'Excipient_concentration': TextInput(attrs={
                'class': 'slider',
                'type': 'number',
                'step': "0.1",

ExcipientFormSet = inlineformset_factory(

This is the template to post to the form:

<form action="" id="form-container" method="POST"> {% csrf_token %} <div class='row'>
     <div class='col'>
       <label for="id_API_batch_number" class="form-label">API batch number : </label>
     <div class='col'>
       {{ parameter_form.API_batch_number }}
   <hr class="my-4">
   <div class='excipient-form'>
     {{ excipient_form }}

     <input type="range" class="slider" name="slidervalue" value='20' max="100" step="0.1" onchange="updateTextInputRange(this.value);">
   <button id="add-form" type="button">Add Excipient</button>
   <hr class="my-4">
   <label for="num6" class="form-label">Total Concentration: </label>
   {{ parameter_form.Total_concentration }}
   <input type="submit" id="submit" class="btn btn-primary" value="Submit">

I'm trying to get the sliders and it's corresponding number field to "sync".

enter image description here

This is the JS I have at the moment.

//Update Textbox value from slider value
  function updateTextInputRange(val) {

    document.getElementByID('excipient_concentration').value = val;  // text input

Some of the things I tried:

  1. Finding out the ID for each instance of the slider and number input. This failed as every instance has the same ID.
  2. Tried using multiple widgets in the same form. This failed the html element just took the properties of the final widget properties.
  3. Tried adding another field in the model and using that as a slider in the forms widget. This does not allow me to "sync" the slider and number values without making a call back to the server.

Any ideas on how this can be accomplished?

Django documentation. MultiWidget. In your Case:

widget = MultiWidget(widgets={'Excipient_type': Select, 'Excipient_concentration': TextInput})

But try to read documentation. More here:

Back to Top