[Django]-Django: Changing auto_id of ModelForm based form class

3👍

You can override the argument in constructor:

class TestForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(TestForm, self).__init__(auto_id=True, *args, **kwargs)
👤exslim

4👍

class TestForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(TestForm, self).__init__(*args, **kwargs) 
        self.auto_id = True
    class Meta:
        model = Test
👤ndpu

Leave a comment