In the moment of declaration you have no information about model instance ModelForm will be initialized with.
You have to dynamically set choices when model instance is already known and it happens not earlier than in __init__()
method:
class SmsForm(ModelForm):
class Meta:
model = SMS
fields = ['phone', 'state']
widgets = {
'phone': Select(attrs={'class':'form-control',}),
'state': bootStrapButtonSelect( attrs={'class': 'buttons-sms', })
}
def __init__(self, *args, **kwargs):
super(SmsForm, self).__init__(*args **kwargs)
self.fields['phone'].widget.choices = \
phoneSMS.objects.filter(sms=self.instance.sms) \
.values_list('id', 'phone')
Still be careful as nobody guaranties that self.instance is set - it depends on optional instance argument. So better attach proper conditions and way of handling such case.