Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9787 closed (invalid)

PasswordInput widget's max_length wrong output.

Reported by: patrick91 Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hi,
when I use this code:

#forms.py

class TestForm(forms.Form):
    check_password = forms.CharField(_('Password (verifica)'), widget=forms.PasswordInput)

#template.html

{{ form.as_table }}

I get this output:

<form action="." method="post">
<table>
 <tr>
  <td>
   <label for="id_nick_name">Nickname</label>
  </td>
  <td>
   <input id="id_password" type="password" name="password" maxlength="&lt;django.utils.functional.__proxy__ object at 0x2b5bb4d407d0&gt;" />
  </td>
 </tr>
</table>

the part: maxlength="&lt;django.utils.functional.proxy object at 0x2b5bb4d407d0&gt;" seems strange, i don't know hot get the correct ouput.

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The first positional argument for a forms.CharField is the maximum length for the field, see:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#charfield

You are passing in _('Password (verifica)'). I'm assuming you mean that to be the label, in which case your form should be:

class TestForm(forms.Form):
    check_password = forms.CharField(label=_('Password (verifica)'), widget=forms.PasswordInput)

comment:2 Changed 5 years ago by patrick91

thank you very much :)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.