class Meta:
model = LectureSession
fields = ['elf', 'elf_notes']
widgets = {
'elf_notes': Textarea(attrs={'cols': 80, 'rows': 40}),
}
I want to add default text to the elf_notes text area.
There are multiple ways of doing it, you can pass initial data when you initialize your form:
initial = {'elf_notes': 'This is default text.'}
form = MyForm(initial=initial)
Or you can set it after initialization, something like this:
class MyForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['elf_notes'].initial = 'This is default text.'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With