The correct way is to set read-only in the Form class, in this case the example code could be:
class ExampleForm(BaseForm): name = forms.CharField(label=_('Name'), required=True, widget=forms.TextInput(attrs={'readonly': 'readonly'}))