[Fixed]-Add extra field to ModelForm

19👍

If you want to set a default.

extra_field = forms.CharField(label='Name of Institution', initial="harvard")

If you want to dynamically set a value put it on form initialization:

def __init__(self, *args, **kwargs):
    super(form, self).__init__(*args, **kwargs)
    self.fields['extra_field'].initial = "harvard"

Leave a comment