Django Autocomplete Light - - Cloning an autocomplete field dynamically


Lets say I have this form:

class PostForm:
    tag = forms.ModelChoiceField(queryset=Tags.objects.all(), 
                                                  widget=autocomplete.ModelSelect2(url='tag_autocomplete', 'attrs': {'id: 'tag_1'}}))

In otherwords, it contains an autocomplete field that calls tag_autocomplete to fetch a possible list of results from the search. (In the actual form, there are more fields but I am trying to keep the code as simple as possible)

I also have a view that takes the above form and renders it in a html file like this:

    {{ post_form.tag }}
    <input type="submit">

How can I create a duplicate of the autocomplete field, for example, by clicking an “Add Additional Tag” button. Normally, you can just get a duplicate of an input element by cloning it and changing the new one’s ID/name before appending it to the html. However, this is not possible here as DAL does some additional rendering which adds additonal tags below the form element (I tried to understand how it works from the document but I couldn’t).