class SomeForm(ModelForm):

    def __init__(self, *args, **kwargs):
        super(SomeForm, self).__init__(*args, **kwargs)
try:
    canchangedriver = self.instance.somefunc()
except AttributeError:
    canchangedriver = True
if not canchangedriver:
    self.fields['Drivers'].widget = HiddenInput()


class Meta:
    model = SomeModel
django: exclude certain form elements based on a condition