Patlola Praveen
Patlola Praveen

Reputation: 770

How to read django autocomplete lights value to generate choices dynamically?

Hey i would like to get the value of django autocomplete light in the model form and generate choices for the next fields accordingly.

class GroupPropertiesForm(forms.ModelForm):
  <strike>fields['equipment_grade']: forms.ChoiceField(
            choices=[(o.id, str(o))
                     for o in GroupProperties.objects.all(group=???group???)]</strike>
 class Meta:
    model = GroupProperties
    fields = ('group', 'bells')
    widgets = {
        'group': autocomplete.ModelSelect2(
            url='groups-autocomplete')
        )
    }

Upvotes: 0

Views: 390

Answers (1)

Patlola Praveen
Patlola Praveen

Reputation: 770

This is not the correct way to implement this functionality, autocomplete light will provide information as a forward for the next attribute as they have written Django auto complete light documentation

Upvotes: 1

Related Questions