Reputation: 770
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
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