Consider:
>>>jr.operators.values_list('id')
[(1,), (2,), (3,)]
How does one simplify further to:
['1', '2', '3']
The purpose:
class ActivityForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ActivityForm, self).__init__(*args, **kwargs)
if self.initial['job_record']:
jr = JobRecord.objects.get(pk=self.initial['job_record'])
# Operators
self.fields['operators'].queryset = jr.operators
# select all operators by default
self.initial['operators'] = jr.operators.values_list('id') # refined as above.