lundi 29 juin 2015

Django, initial checked input


How can I pre-check a CheckboxInput of a form?

I tried this in __init__:

self.fields['name_field'].widget.attrs['checked'] = 'checked'

But it doesn't work..

My field is a boolean field in model and in my form it's a checkbox input.


Aucun commentaire:

Enregistrer un commentaire