I want my CheckboxInput was checked by default :
My models :
class Sub(models.Model):
user = models.OneToOneField(User)
bata
Add 'checked' attribute to your Checkbox Input field widget in presentationForm. So that your code becomes :
class presentationForm(forms.ModelForm):
class Meta :
model = Sub
widgets = {
'batata': forms.CheckboxInput(attrs={'id':'batata', 'checked' : ''}),
}
def __init__(self, *args, **kwargs):
self.valbata = kwargs.pop("arg_bata")
super(presentationForm, self).__init__(*args, **kwargs)
self.fields['batata'].initial = True