2👍
You have to do that in __init__
method, like this:
class MergeStorageItemsForm(forms.Form):
storageitem1 = forms.ModelChoiceField(queryset=StorageItem.objects.none())
def __init__(self, *args, **kwargs):
self.storage_pk = kwargs.pop('pk')
super(MergeStorageItemsForm, self).__init__(*args, **kwargs)
self.fileds['storageitem1'].queryset = StorageItem.objects.get(pk=self.storage_pk)
Source:stackexchange.com