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'),
    )
)
有帮助吗?

解决方案 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',}
                                     )
                              )

其他提示

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

PrependedText('p_number', 'P', css_class='input-xlarge', autocomplete="off"),
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top