3

I'm using django-autocomplete-light in a django admin change_form.html page, however I need to change dynamically the GET parameters of the URL depending on another field.

I have already tried to replicate this answer django-autocomplete-light add parameter to query url, but failed since I am using version 3

Tried this way:

$("#id_city").change(function(){
    url = '{% url "custom-pop-autocomplete" %}';
    $('#id_p').attr('data-autocomplete-light-url', url + `?city=${$(this).val()}`);
    $('#id_p').trigger('autocompleteLightInitialize');
});

This way:

$('[data-autocomplete-light-function=select2]:not([id*="__prefix__"])').each(function() {
    $(this).initialize
});

and this way:

$('[data-autocomplete-light-function=select2]:not([id*="__prefix__"])').each(function() {
    window.__dal__initialize(this);
});

None of them working to reinitialize django-autocomplete-light. I just need to change the URL.

0 Answers0