1👍
✅
You need to call the super()
class in __init__
def __init__(self, *args, **kwargs):
self.building_id = kwargs.pop('building_id')
super(RoomTypeForm, self).__init__(*args, **kwargs)
self.fields['Capacity'].queryset = Capacity.objects.filter(Building=self.building_id)
Or if you are using python3, you could just do:
super().__init__(*args, **kwargs)
Another side note, it is standard practice to specify a list or a tuple in the fields
. You specified a set.
Source:stackexchange.com