Question

I am using django-crispy-forms and wondering how to disable autocomplete for a specific field. The field is a forms.IntegerField that is prependedtext.

p_number = forms.IntegerField()

helper = FormHelper()
helper.form_class = 'form-horizontal'

helper.layout = Layout(
    Row(
        PrependedText('p_number', 'P',css_class='input-xlarge'),
        Submit('submit','Submit', css_class='btn-primary'),
    )
)
Was it helpful?

Solution 2

Bootstrap has autocomplete input attibute to allow disable autocomplete. You can set to off this attribute through django-crispy-forms in this way:

p_number = forms.IntegerField(
               widget=forms.TextInput(
                                  attrs={'autocomplete':'off',}
                                     )
                              )

OTHER TIPS

The crispy-forms way of doing this would be as easy as:

PrependedText('p_number', 'P', css_class='input-xlarge', autocomplete="off"),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top